From f7b5c7df68a629999169ddef9b7a1312dd53ffd5 2013-08-01 19:09:37 From: Thomas Robitaille Date: 2013-08-01 19:09:37 Subject: [PATCH] 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. --- diff --git a/IPython/nbconvert/post_processors/pdf.py b/IPython/nbconvert/post_processors/pdf.py index fffa3ea..4c3f28b 100644 --- a/IPython/nbconvert/post_processors/pdf.py +++ b/IPython/nbconvert/post_processors/pdf.py @@ -15,9 +15,8 @@ Contains writer for writing nbconvert output to PDF. import subprocess import os -import shlex -from IPython.utils.traitlets import Integer, Unicode, Bool +from IPython.utils.traitlets import Integer, List, Bool from .base import PostProcessorBase @@ -31,7 +30,7 @@ class PDFPostProcessor(PostProcessorBase): How many times pdflatex will be called. """) - compiler = Unicode(u'pdflatex {0}', config=True, help=""" + compiler = List(["pdflatex", "{filename}"], config=True, help=""" Shell command used to compile PDF.""") verbose = Bool(False, config=True, help=""" @@ -43,8 +42,8 @@ class PDFPostProcessor(PostProcessorBase): Consume and write Jinja output a PDF. See files.py for more... """ - command = self.compiler.format(shlex.quote(input)) - self.log.info("Building PDF: `%s`", command) + command = [c.format(filename=input) for c in self.compiler] + self.log.info("Building PDF: `%s`", ' '.join(command)) for index in range(self.iteration_count): if self.verbose: subprocess.Popen(command, shell=True)