##// END OF EJS Templates
Provide a list of the command and argument to subprocess for PDF post-processor, which is a better way to avoid issues if there are spaces in the filename.
Thomas Robitaille -
Show More
@@ -1,53 +1,52 b''
1 1 """
2 2 Contains writer for writing nbconvert output to PDF.
3 3 """
4 4 #-----------------------------------------------------------------------------
5 5 #Copyright (c) 2013, the IPython Development Team.
6 6 #
7 7 #Distributed under the terms of the Modified BSD License.
8 8 #
9 9 #The full license is in the file COPYING.txt, distributed with this software.
10 10 #-----------------------------------------------------------------------------
11 11
12 12 #-----------------------------------------------------------------------------
13 13 # Imports
14 14 #-----------------------------------------------------------------------------
15 15
16 16 import subprocess
17 17 import os
18 import shlex
19 18
20 from IPython.utils.traitlets import Integer, Unicode, Bool
19 from IPython.utils.traitlets import Integer, List, Bool
21 20
22 21 from .base import PostProcessorBase
23 22
24 23 #-----------------------------------------------------------------------------
25 24 # Classes
26 25 #-----------------------------------------------------------------------------
27 26 class PDFPostProcessor(PostProcessorBase):
28 27 """Writer designed to write to PDF files"""
29 28
30 29 iteration_count = Integer(3, config=True, help="""
31 30 How many times pdflatex will be called.
32 31 """)
33 32
34 compiler = Unicode(u'pdflatex {0}', config=True, help="""
33 compiler = List(["pdflatex", "{filename}"], config=True, help="""
35 34 Shell command used to compile PDF.""")
36 35
37 36 verbose = Bool(False, config=True, help="""
38 37 Whether or not to display the output of the compile call.
39 38 """)
40 39
41 40 def call(self, input):
42 41 """
43 42 Consume and write Jinja output a PDF.
44 43 See files.py for more...
45 44 """
46 command = self.compiler.format(shlex.quote(input))
47 self.log.info("Building PDF: `%s`", command)
45 command = [c.format(filename=input) for c in self.compiler]
46 self.log.info("Building PDF: `%s`", ' '.join(command))
48 47 for index in range(self.iteration_count):
49 48 if self.verbose:
50 49 subprocess.Popen(command, shell=True)
51 50 else:
52 51 with open(os.devnull, 'wb') as null:
53 52 subprocess.Popen(command, shell=True, stdout=null)
General Comments 0
You need to be logged in to leave comments. Login now