##// END OF EJS Templates
Merge pull request #3948 from minrk/sphinx-dir...
Merge pull request #3948 from minrk/sphinx-dir Sphinx and PDF tweaks for nbconvert: - add `--interaction=batchmode` to pdflatex call to avoid waiting for interactive input. - use sphinx.package_dir to find texinputs directory regardless of on-disk location. Closes #3894.

File last commit:

r12056:fe29ad09
r12057:c293fc54 merge
Show More
pdf.py
51 lines | 1.9 KiB | text/x-python | PythonLexer
Jonathan Frederic
Fixed errors after testing...
r11742 """
Contains writer for writing nbconvert output to PDF.
"""
#-----------------------------------------------------------------------------
#Copyright (c) 2013, the IPython Development Team.
#
#Distributed under the terms of the Modified BSD License.
#
#The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
import subprocess
import os
Thomas Robitaille
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.
r11911 from IPython.utils.traitlets import Integer, List, Bool
Jonathan Frederic
Fixed errors after testing...
r11742
Jonathan Frederic
Moved PDF logic into Post-Processor class
r11747 from .base import PostProcessorBase
Jonathan Frederic
Fixed errors after testing...
r11742
#-----------------------------------------------------------------------------
# Classes
#-----------------------------------------------------------------------------
Jonathan Frederic
Moved PDF logic into Post-Processor class
r11747 class PDFPostProcessor(PostProcessorBase):
Jonathan Frederic
Fixed errors after testing...
r11742 """Writer designed to write to PDF files"""
iteration_count = Integer(3, config=True, help="""
How many times pdflatex will be called.
""")
MinRK
add `--interaction=batchmode` to pdflatex call...
r12056 command = List(["pdflatex", "--interaction=batchmode", "{filename}"], config=True, help="""
Jonathan Frederic
flavor=template
r11745 Shell command used to compile PDF.""")
Jonathan Frederic
Moved PDF logic into Post-Processor class
r11747 verbose = Bool(False, config=True, help="""
Whether or not to display the output of the compile call.
""")
def call(self, input):
Jonathan Frederic
Fixed errors after testing...
r11742 """
Consume and write Jinja output a PDF.
See files.py for more...
"""
Thomas Robitaille
Renamed compiler to command
r11922 command = [c.format(filename=input) for c in self.command]
Thomas Robitaille
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.
r11911 self.log.info("Building PDF: `%s`", ' '.join(command))
Paul Ivanov
wait for subprocess to finish
r11961 with open(os.devnull, 'wb') as null:
Jonathan Frederic
FIXED logic of verbose flag in PDF post processor
r12048 stdout = null if not self.verbose else None
Paul Ivanov
wait for subprocess to finish
r11961 for index in range(self.iteration_count):
p = subprocess.Popen(command, stdout=stdout)
p.wait()