diff --git a/nbconvert.py b/nbconvert.py index af3f9b5..92777c7 100755 --- a/nbconvert.py +++ b/nbconvert.py @@ -26,13 +26,10 @@ import os #From IPython #All the stuff needed for the configurable things from IPython.config.application import Application -from IPython.config.loader import ConfigFileNotFound -from IPython.utils.traitlets import Unicode, Bool #Local imports -from api.exporter import Exporter -from converters.config import GlobalConfigurable #TODO -from converters.transformers import (ExtractFigureTransformer) #TODO +from nbconvert.api.convert import export_by_name +from nbconvert.api.exporter import Exporter #----------------------------------------------------------------------------- #Globals and constants @@ -78,8 +75,6 @@ class NbconvertApp(Application): #Register class here to have help with help all self.classes.insert(0, Exporter) - self.classes.insert(0, ExtractFigureTransformer) - self.classes.insert(0, GlobalConfigurable) def start(self, argv=None): @@ -91,51 +86,57 @@ class NbconvertApp(Application): #Call base super(NbconvertApp, self).start() - #The last arguments in chain of arguments will be used as conversion - ipynb_file = (self.extra_args or [None])[2] - - #If you are writting a custom transformer, append it to the dictionary - #below. - userpreprocessors = {} - - #Create the Jinja template exporter. TODO: Add ability to - #import in IPYNB aswell - exporter = Exporter(config=self.config, preprocessors=userpreprocessors,export_format=export_format) + #The last arguments in chain of arguments will be used as conversion type + ipynb_file = (self.extra_args)[2] + export_type = (self.extra_args)[1] #Export - output, resources = exporter.from_filename(ipynb_file) - if exporter.stdout : + output, resources, exporter = export_by_name(ipynb_file, export_type) + + destination_filename = None + destination_directory = None + if exporter.write: + + #Get the file name without the '.ipynb' (6 chars) extension and then + #remove any addition periods and spaces. The resulting name will + #be used to create the directory that the files will be exported + #into. + out_root = ipynb_file[:-6].replace('.', '_').replace(' ', '_') + destination_filename = os.path.join(out_root+'.'+exporter.fileext) + + destination_directory = out_root+'_files' + if not os.path.exists(destination_directory): + os.mkdir(destination_directory) + + #Write the results + if exporter.stdout or exporter.write: + self._write_results(exporter.stdout, destination_filename, destination_directory, output, resources) + + + def _write_results(self, stdout, destination_filename, destination_directory, output, resources): + if stdout: print(output.encode('utf-8')) - #Get the file name without the '.ipynb' (6 chars) extension and then - #remove any addition periods and spaces. The resulting name will - #be used to create the directory that the files will be exported - #into. - out_root = ipynb_file[:-6].replace('.', '_').replace(' ', '_') - #Write file output from conversion. - if exporter.write : - with io.open(os.path.join(out_root+'.'+exporter.fileext), 'w') as f: + if not destination_filename is None: + with io.open(destination_filename, 'w') as f: f.write(output) #Output any associate figures into the same "root" directory. binkeys = resources.get('figures', {}).get('binary',{}).keys() textkeys = resources.get('figures', {}).get('text',{}).keys() if binkeys or textkeys : - if exporter.write: - files_dir = out_root+'_files' - if not os.path.exists(out_root+'_files'): - os.mkdir(files_dir) + if not destination_directory is None: for key in binkeys: - with io.open(os.path.join(files_dir, key), 'wb') as f: + with io.open(os.path.join(destination_directory, key), 'wb') as f: f.write(resources['figures']['binary'][key]) for key in textkeys: - with io.open(os.path.join(files_dir, key), 'w') as f: + with io.open(os.path.join(destination_directory, key), 'w') as f: f.write(resources['figures']['text'][key]) #Figures that weren't exported which will need to be created by the #user. Tell the user what figures these are. - elif exporter.stdout: + if stdout: print(KEYS_PROMPT_HEAD) print(resources['figures'].keys()) print(KEYS_PROMPT_BODY) diff --git a/nbconvert/api/convert.py b/nbconvert/api/convert.py index bf71b3a..2625abe 100755 --- a/nbconvert/api/convert.py +++ b/nbconvert/api/convert.py @@ -11,11 +11,73 @@ they are converted. # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- +from .exporter import Exporter + +from .html import HtmlExporter +from .latex import LatexExporter +from .markdown import MarkdownExporter +from .python import PythonExporter +from .reveal import RevealExporter +from .rst import RstExporter +from .sphinx import SphinxExporter + +from IPython.nbformat.v3.nbbase import NotebookNode + #----------------------------------------------------------------------------- # Functions #----------------------------------------------------------------------------- -def export_sphinx_report(nb, config=None): - pass +def export(nb, config=None, transformers=None, filters=None, exporter_type=Exporter): + + #Check arguments + if exporter_type is None: + raise TypeError("Exporter is None") + elif not isinstance(exporter_type, Exporter): + raise TypeError("Exporter type does not inherit from Exporter (base)") + + if nb is None: + raise TypeError("nb is None") + + #Create the exporter + exporter_instance = exporter_type(transformers, filters, config) + + #Try to convert the notebook using the appropriate conversion function. + if isinstance(nb, NotebookNode): + return exporter_instance.from_notebook_node(nb), exporter_instance + elif isinstance(nb, str): + return exporter_instance.from_filename(nb), exporter_instance + else: + return exporter_instance.from_file(nb), exporter_instance + + +def export_sphinx(nb, config=None, transformers=None, filters=None): + return export(nb, config, transformers, filters, SphinxExporter) + +def export_html(nb, config=None, transformers=None, filters=None): + return export(nb, config, transformers, filters, HtmlExporter) + +def export_latex(nb, config=None, transformers=None, filters=None): + return export(nb, config, transformers, filters, LatexExporter) + +def export_markdown(nb, config=None, transformers=None, filters=None): + return export(nb, config, transformers, filters, MarkdownExporter) + +def export_python(nb, config=None, transformers=None, filters=None): + return export(nb, config, transformers, filters, PythonExporter) + +def export_reveal(nb, config=None, transformers=None, filters=None): + return export(nb, config, transformers, filters, RevealExporter) + +def export_rst(nb, config=None, transformers=None, filters=None): + return export(nb, config, transformers, filters, RstExporter) + +EXPORT_FUNCTIONS = {"sphinx": export_sphinx, + "html": export_html, + "latex": export_latex, + "markdown": export_markdown, + "python": export_python, + "reveal": export_reveal, + "rst": export_rst} -#TODO: Add basic export/import utility functions. +def export_by_name(nb, template_name, config=None, transformers=None, filters=None): + return EXPORT_FUNCTIONS[template_name](nb, config, transformers, filters) \ No newline at end of file diff --git a/nbconvert/api/exporter.py b/nbconvert/api/exporter.py index e3b441e..8a3098f 100755 --- a/nbconvert/api/exporter.py +++ b/nbconvert/api/exporter.py @@ -23,7 +23,6 @@ from __future__ import print_function, absolute_import # Stdlib imports import io import os -import copy # IPython imports from IPython.config.configurable import Configurable @@ -54,7 +53,6 @@ import transformers.coalescestreams #Standard Jinja2 environment constants TEMPLATE_PATH = "/../templates/" TEMPLATE_SKELETON_PATH = "/../templates/skeleton/" -TEMPLATE_EXTENSION = ".tpl" #Jinja2 extensions to load. JINJA_EXTENSIONS = ['jinja2.ext.loopcontrols'] @@ -63,13 +61,6 @@ JINJA_EXTENSIONS = ['jinja2.ext.loopcontrols'] # Classes and functions #----------------------------------------------------------------------------- class Exporter(Configurable): - """ A Jinja2 base converter templates - - Pre-process the IPYNB files, feed it through Jinja2 templates, - and spit an converted files and a data object with other data - should be mostly configurable - """ - pre_transformer_order = List(['haspyout_transformer'], config=True, help= """ @@ -99,6 +90,9 @@ class Exporter(Configurable): along with potential extracted resources.""" ) + #Extension that the template files use. + template_extension = ".tpl" + #Processors that process the input data prior to the export, set in the #constructor for this class. preprocessors = [] @@ -106,32 +100,11 @@ class Exporter(Configurable): # Public Constructor ##################################################### def __init__(self, preprocessors=None, jinja_filters=None, config=None, **kw): - """ Init a new converter. - - config: the Configurable config object to pass around. - - preprocessors: dict of **available** key/value function to run on - ipynb json data before conversion to extract/in-line file. - See `transformer.py` and `ConfigurableTransformers` - - set the order in which the transformers should apply - with the `pre_transformer_order` trait of this class - - transformers registered by this key will take precedence on - default one. - - jinja_filters: dict of supplementary jinja filter that should be made - available in template. If those are of Configurable Class type, - they will be instanciated with the config object as argument. - - user defined filter will overwrite the one available by default. - """ #Call the base class constructor super(Exporter, self).__init__(config=config, **kw) #Standard environment - self.ext = TEMPLATE_EXTENSION self._init_environment() #TODO: Implement reflection style methods to get user transformers. @@ -156,63 +129,35 @@ class Exporter(Configurable): self.environment.filters[key] = user_filter(config=config) else: self.environment.filters[key] = user_filter - - - #Set the default datatype priority. - self._set_datatype_priority(['svg', 'png', 'latex', 'jpg', 'jpeg','text']) - # Public methods ######################################### def from_notebook_node(self, nb): - """Export NotebookNode instance - - nb: NotebookNode to export. - - Returns both the converted ipynb file and a dict containing the - resources created along the way via the transformers and Jinja2 - processing. - """ - nb, resources = self._preprocess(nb) #Load the template file. - self.template = self.environment.get_template(self.template_file+self.ext) + self.template = self.environment.get_template(self.template_file+self.template_extension) return self.template.render(nb=nb, resources=resources), resources def from_filename(self, filename): - """Read and export a notebook from a filename - - filename: Filename of the notebook file to export. - - Returns both the converted ipynb file and a dict containing the - resources created along the way via the transformers and Jinja2 - processing. - """ with io.open(filename) as f: return self.from_notebook_node(nbformat.read(f, 'json')) def from_file(self, file_stream): - """Read and export a notebook from a file stream - - file_stream: File handle of file that contains notebook data. - - Returns both the converted ipynb file and a dict containing the - resources created along the way via the transformers and Jinja2 - processing. - """ - return self.from_notebook_node(nbformat.read(file_stream, 'json')) def register_transformer(self, transformer): if MetaHasTraits(transformer): - self.preprocessors.append(transformer(config=self.config)) + transformer_instance = transformer(config=self.config) + self.preprocessors.append(transformer_instance) + return transformer_instance else: self.preprocessors.append(transformer) + return transformer def register_filter(self, name, filter): @@ -222,6 +167,7 @@ class Exporter(Configurable): self.environment.filters[name] = filter return self.environment.filters[name] + # Protected and Private methods ######################################### def _register_transformers(self): @@ -230,7 +176,6 @@ class Exporter(Configurable): #Remember the figure extraction transformer so it can be enabled and #disabled easily later. self.extract_figure_transformer = self.register_transformer(transformers.extractfigure.ExtractFigureTransformer) - self.extract_figure_transformer.enabled = False def _register_filters(self): @@ -250,11 +195,6 @@ class Exporter(Configurable): self.register_filter('rm_fake', filters.strings.rm_fake) self.register_filter('rm_math_space', filters.latex.rm_math_space) self.register_filter('wrap', filters.strings.wrap) - - - def _set_datatype_priority(self, priority): - self.extract_figure_transformer.display_data_priority=copy.copy(priority) - self.display_data_priority=copy.copy(priority) def _init_environment(self): @@ -268,11 +208,6 @@ class Exporter(Configurable): def _preprocess(self, nb): - """ Preprocess the notebook using the transformers specific - for the current export format. - - nb: Notebook to preprocess - """ #Dict of 'resources' that can be filled by the preprocessors. resources = {} @@ -282,4 +217,3 @@ class Exporter(Configurable): for transformer in self.preprocessors: nb, resources = transformer(nb, resources) return nb, resources - diff --git a/nbconvert/api/html.py b/nbconvert/api/html.py index 2cc8e5b..993f79c 100644 --- a/nbconvert/api/html.py +++ b/nbconvert/api/html.py @@ -1,4 +1,4 @@ - """TODO: Docstring +"""TODO: Docstring """ #----------------------------------------------------------------------------- @@ -16,27 +16,22 @@ # local import import exporter import transformers.csshtmlheader +from IPython.utils.traitlets import Unicode #----------------------------------------------------------------------------- # Classes #----------------------------------------------------------------------------- class HtmlExporter(exporter.Exporter): - def __init__(self, preprocessors=None, jinja_filters=None, config=None, full_html=True, **kw): - - #Call base class constructor. - super(exporter.Exporter, self).__init__(preprocessors, jinja_filters, config, **kw) + file_extension = Unicode( + 'html', config=True, + help="Extension of the file that should be written to disk" + ) + + template_file = Unicode( + 'fullhtml', config=True, + help="Name of the template file to use") - #Set defaults - self.file_extension = "html" - self.extract_figure_transformer.enabled = True - - #Load the correct template - if full_html: - self.template_file = "fullhtml" - else: - self.template_file = "basichtml" - def _register_transformers(self): #Register the transformers of the base class. diff --git a/nbconvert/api/latex.py b/nbconvert/api/latex.py index e3669b4..d72cc5d 100755 --- a/nbconvert/api/latex.py +++ b/nbconvert/api/latex.py @@ -1,12 +1,3 @@ - """Latex exporter for the notebook conversion pipeline. - -This module defines Exporter, a highly configurable converter -that uses Jinja2 to export notebook files into different format. - -You can register both pre-transformers that will act on the notebook format -before conversion and jinja filter that would then be available in the templates -""" - #----------------------------------------------------------------------------- # Copyright (c) 2013, the IPython Development Team. # @@ -20,18 +11,13 @@ before conversion and jinja filter that would then be available in the templates #----------------------------------------------------------------------------- # Stdlib imports -import io import os # IPython imports -from IPython.config.configurable import Configurable -from IPython.nbformat import current as nbformat -from IPython.utils.traitlets import MetaHasTraits, Unicode, List, Bool -from IPython.utils.text import indent +from IPython.utils.traitlets import Unicode # other libs/dependencies from jinja2 import Environment, FileSystemLoader -from markdown import markdown # local import import exporter @@ -45,7 +31,6 @@ from transformers.latex import LatexTransformer #Latex Jinja2 constants LATEX_TEMPLATE_PATH = "/../templates/tex/" LATEX_TEMPLATE_SKELETON_PATH = "/../templates/tex/skeleton/" -LATEX_TEMPLATE_EXTENSION = ".tplx" #Special Jinja2 syntax that will not conflict when exporting latex. LATEX_JINJA_COMMENT_BLOCK = ["((=", "=))"] @@ -56,28 +41,28 @@ LATEX_JINJA_LOGIC_BLOCK = ["((*", "*))"] # Classes and functions #----------------------------------------------------------------------------- class LatexExporter(exporter.Exporter): - """ A Jinja2 latex exporter - Preprocess the ipynb files, feed it through jinja templates, - and spit an converted files and a data object with other data - should be mostly configurable - """ + #Extension that the template files use. + template_extension = ".tplx" + + file_extension = Unicode( + 'tex', config=True, + help="Extension of the file that should be written to disk") + template_file = Unicode( + 'latex_base', config=True, + help="Name of the template file to use") + def __init__(self, preprocessors=None, jinja_filters=None, config=None, **kw): #Call base class constructor. super(exporter.Exporter, self).__init__(preprocessors, jinja_filters, config, **kw) - - #Set defaults - self.file_extension = "tex" - self._set_datatype_priority(['latex', 'svg', 'png', 'jpg', 'jpeg' , 'text']) - self.extract_figure_transformer.enabled = True + + self.extract_figure_transformer.display_data_priority = ['latex', 'svg', 'png', 'jpg', 'jpeg' , 'text'] self.extract_figure_transformer.extra_ext_map={'svg':'pdf'} - self.template_file = "latex_base" def _init_environment(self): - self.ext = LATEX_TEMPLATE_EXTENSION self.environment = Environment( loader=FileSystemLoader([ os.path.dirname(os.path.realpath(__file__)) + LATEX_TEMPLATE_PATH, diff --git a/nbconvert/api/markdown.py b/nbconvert/api/markdown.py index a4aa111..1e76747 100644 --- a/nbconvert/api/markdown.py +++ b/nbconvert/api/markdown.py @@ -1,5 +1,3 @@ -"""TODO: Docstring -""" #----------------------------------------------------------------------------- # Copyright (c) 2013, the IPython Development Team. @@ -15,18 +13,17 @@ # local import import exporter +from IPython.utils.traitlets import Unicode #----------------------------------------------------------------------------- # Classes #----------------------------------------------------------------------------- class MarkdownExporter(exporter.Exporter): - def __init__(self, preprocessors=None, jinja_filters=None, config=None, **kw): - - #Call base class constructor. - super(exporter.Exporter, self).__init__(preprocessors, jinja_filters, config, **kw) + file_extension = Unicode( + 'md', config=True, + help="Extension of the file that should be written to disk") - #Set defaults - self.file_extension = "md" - self.extract_figure_transformer.enabled = True - self.template_file = "markdown" + template_file = Unicode( + 'markdown', config=True, + help="Name of the template file to use") diff --git a/nbconvert/api/python.py b/nbconvert/api/python.py index eb3c45b..bebc8fa 100644 --- a/nbconvert/api/python.py +++ b/nbconvert/api/python.py @@ -15,20 +15,26 @@ # local import import exporter +from IPython.utils.traitlets import Unicode #----------------------------------------------------------------------------- # Classes #----------------------------------------------------------------------------- class PythonExporter(exporter.Exporter): + file_extension = Unicode( + 'py', config=True, + help="Extension of the file that should be written to disk") + + template_file = Unicode( + 'python', config=True, + help="Name of the template file to use") + def __init__(self, preprocessors=None, jinja_filters=None, config=None, armor=False, **kw): #Call base class constructor. super(exporter.Exporter, self).__init__(preprocessors, jinja_filters, config, **kw) #Set defaults - self.file_extension = "py" - if armor: - self.template_file = "python-armor" - else: - self.template_file = "python" + self.extract_figure_transformer.enabled = False + diff --git a/nbconvert/api/reveal.py b/nbconvert/api/reveal.py index 7405679..e4bbf65 100644 --- a/nbconvert/api/reveal.py +++ b/nbconvert/api/reveal.py @@ -1,4 +1,4 @@ - """TODO: Docstring +"""TODO: Docstring """ #----------------------------------------------------------------------------- @@ -16,21 +16,21 @@ # local import import html_exporter import transformers.revealhelp +from IPython.utils.traitlets import Unicode #----------------------------------------------------------------------------- # Classes #----------------------------------------------------------------------------- class RevealExporter(html_exporter.HtmlExporter): - def __init__(self, preprocessors=None, jinja_filters=None, config=None, **kw): - - #Call base class constructor. - super(html_exporter.HtmlExporter, self).__init__(preprocessors, jinja_filters, config, **kw) - - #Set defaults - self.file_extension = "reveal.html" - self.template_file = "reveal" + file_extension = Unicode( + 'reveal.html', config=True, + help="Extension of the file that should be written to disk") + template_file = Unicode( + 'reveal', config=True, + help="Name of the template file to use") + def _register_transformers(self): #Register the transformers of the base class. diff --git a/nbconvert/api/rst.py b/nbconvert/api/rst.py index e24f982..e1edc8c 100644 --- a/nbconvert/api/rst.py +++ b/nbconvert/api/rst.py @@ -1,4 +1,4 @@ - """TODO: Docstring +"""TODO: Docstring """ #----------------------------------------------------------------------------- @@ -15,23 +15,21 @@ # local import import exporter +from IPython.utils.traitlets import Unicode #----------------------------------------------------------------------------- # Classes #----------------------------------------------------------------------------- class RstExporter(exporter.Exporter): - def __init__(self, preprocessors=None, jinja_filters=None, config=None, **kw): - - #Call base class constructor. - super(exporter.Exporter, self).__init__(preprocessors, jinja_filters, config, **kw) - - #Set defaults - self.file_extension = "rst" - self.template_file = "rst" - self.extract_figure_transformer.enabled = True - + file_extension = Unicode( + 'rst', config=True, + help="Extension of the file that should be written to disk") + template_file = Unicode( + 'rst', config=True, + help="Name of the template file to use") + def _register_filters(self): #Register the filters of the base class. diff --git a/nbconvert/api/sphinx.py b/nbconvert/api/sphinx.py index a84933d..8806acf 100644 --- a/nbconvert/api/sphinx.py +++ b/nbconvert/api/sphinx.py @@ -1,5 +1,3 @@ - """TODO: Docstring -""" #----------------------------------------------------------------------------- # Copyright (c) 2013, the IPython Development Team. @@ -14,35 +12,23 @@ #----------------------------------------------------------------------------- # local import -import latex_exporter - +import latex +from IPython.utils.traitlets import Unicode +from transformers.sphinx import SphinxTransformer #----------------------------------------------------------------------------- # Classes #----------------------------------------------------------------------------- -class SphinxExporter(latex_exporter.LatexExporter): - - def __init__(self, preprocessors=None, jinja_filters=None, config=None, sphinx_type="howto", **kw): - - #Call base class constructor. - super(latex_exporter.LatexExporter, self).__init__(preprocessors, jinja_filters, config, **kw) - - #Defaults - self.template_file = "latex_sphinx_" + sphinx_type - - def _register_filters(self): - - #Register the filters of the base class. - super(latex_exporter.LatexExporter, self)._register_filters() - - #Add latex filters to the Jinja2 environment - #self.register_filter('escape_tex', filters.latex.escape_tex) +class SphinxExporter(latex.LatexExporter): + template_file = Unicode( + 'sphinxhowto', config=True, + help="Name of the template file to use") def _register_transformers(self): #Register the transformers of the base class. - super(latex_exporter.LatexExporter, self)._register_transformers() + super(latex.LatexExporter, self)._register_transformers() - #Register latex transformer - #self.register_transformer(LatexTransformer) + #Register sphinx latex transformer + self.register_transformer(SphinxTransformer) diff --git a/nbconvert/filters/ansi.py b/nbconvert/filters/ansi.py index d382ad7..bd7293a 100644 --- a/nbconvert/filters/ansi.py +++ b/nbconvert/filters/ansi.py @@ -1,33 +1,10 @@ -# ANSI color functions: import re -def remove_ansi(src): - """Strip all ANSI color escape sequences from input string. - - Parameters - ---------- - src : string - Returns - ------- - string - """ +def remove_ansi(src): return re.sub(r'\033\[(0|\d;\d\d)m', '', src) def ansi2html(txt): - """Render ANSI colors as HTML colors - - This is equivalent to util.fixConsole in utils.js - - Parameters - ---------- - txt : string - - Returns - ------- - string - """ - ansi_colormap = { '30': 'ansiblack', '31': 'ansired', @@ -49,6 +26,7 @@ def ansi2html(txt): '"': '"', '`': '`', } + for c, escape in html_escapes.iteritems(): txt = txt.replace(c, escape) @@ -61,6 +39,7 @@ def ansi2html(txt): while m: cmds = m.groups()[0].split(';') closer = '' if opened else '' + # True if there is there more than one element in cmds, *or* # if there is only one but it is not equal to a string of zeroes. opened = len(cmds) > 1 or cmds[0] != '0' * len(cmds[0]) @@ -79,4 +58,4 @@ def ansi2html(txt): if opened: txt += '' - return txt + return txt \ No newline at end of file diff --git a/nbconvert/filters/datatypefilter.py b/nbconvert/filters/datatypefilter.py index 5167c25..db7aba2 100755 --- a/nbconvert/filters/datatypefilter.py +++ b/nbconvert/filters/datatypefilter.py @@ -1,4 +1,4 @@ -"""Filter used to select the first prefered output format available. +"""Filter used to select the first preferred output format available. The filter contained in the file allows the converter templates to select the output format that is most valuable to the active export format. The @@ -16,11 +16,20 @@ GlobalConfigurable.display_data_priority #----------------------------------------------------------------------------- # Classes and functions #----------------------------------------------------------------------------- -class DataTypeFilter(GlobalConfigurable): - """ Returns the prefered display format """ +class DataTypeFilter(object): + """ Returns the preferred display format """ - def __init__(self, config=None, **kw): - super(DataTypeFilter, self).__init__(config=config, **kw) + display_data_priority = None + + def __init__(self, display_data_priority): + super(object, self).__init__() + + #Make sure that the display data priority variably is not None. + if self.display_data_priority is None: + raise TypeError + else: + self.display_data_priority = display_data_priority + def __call__(self, output): """ Return the first available format in the priority """ diff --git a/nbconvert/filters/latex.py b/nbconvert/filters/latex.py index 63e1293..035ce4b 100755 --- a/nbconvert/filters/latex.py +++ b/nbconvert/filters/latex.py @@ -33,8 +33,6 @@ LATEX_SUBS = ( #----------------------------------------------------------------------------- # Functions #----------------------------------------------------------------------------- - -#TODO: Comment me. def escape_tex(value): newval = value for pattern, replacement in LATEX_SUBS: diff --git a/nbconvert/filters/strings.py b/nbconvert/filters/strings.py index f302be3..d3922cc 100755 --- a/nbconvert/filters/strings.py +++ b/nbconvert/filters/strings.py @@ -1,6 +1,6 @@ """String utilities. -Contains a collection of usefull string manipulations functions. +Contains a collection of useful string manipulations functions. """ #----------------------------------------------------------------------------- # Copyright (c) 2013, the IPython Development Team. diff --git a/nbconvert/templates/latex/latex_base.tplx b/nbconvert/templates/latex/base.tplx similarity index 100% rename from nbconvert/templates/latex/latex_base.tplx rename to nbconvert/templates/latex/base.tplx diff --git a/nbconvert/templates/latex/fncychap.sty b/nbconvert/templates/latex/fncychap.sty deleted file mode 100644 index 9a56c04..0000000 --- a/nbconvert/templates/latex/fncychap.sty +++ /dev/null @@ -1,683 +0,0 @@ -%%% Copyright Ulf A. Lindgren -%%% -%%% Note Premission is granted to modify this file under -%%% the condition that it is saved using another -%%% file and package name. -%%% -%%% Revision 1.1 (1997) -%%% -%%% Jan. 8th Modified package name base date option -%%% Jan. 22th Modified FmN and FmTi for error in book.cls -%%% \MakeUppercase{#}->{\MakeUppercase#} -%%% Apr. 6th Modified Lenny option to prevent undesired -%%% skip of line. -%%% Nov. 8th Fixed \@chapapp for AMS -%%% -%%% Revision 1.2 (1998) -%%% -%%% Feb. 11th Fixed appendix problem related to Bjarne -%%% Aug. 11th Fixed problem related to 11pt and 12pt -%%% suggested by Tomas Lundberg. THANKS! -%%% -%%% Revision 1.3 (2004) -%%% Sep. 20th problem with frontmatter, mainmatter and -%%% backmatter, pointed out by Lapo Mori -%%% -%%% Revision 1.31 (2004) -%%% Sep. 21th problem with the Rejne definition streched text -%%% caused ugly gaps in the vrule aligned with the title -%%% text. Kindly pointed out to me by Hendri Adriaens -%%% -%%% Revision 1.32 (2005) -%%% Jun. 23th compatibility problem with the KOMA class 'scrbook.cls' -%%% a remedy is a redefinition of '\@schapter' in -%%% line with that used in KOMA. The problem was pointed -%%% out to me by Mikkel Holm Olsen -%%% -%%% Revision 1.33 (2005) -%%% Aug. 9th misspelled ``TWELV'' corrected, the error was pointed -%%% out to me by George Pearson -%%% -%%% Revision 1.34 (2007) -%%% Added an alternative to Lenny provided by Peter -%%% Osborne (2005-11-28) -%%% Corrected front, main and back matter, based on input -%%% from Bas van Gils (2006-04-24) -%%% Jul. 30th Added Bjornstrup option provided by Jean-Marc -%%% Francois (2007-01-05). -%%% Reverted to \MakeUppercase{#} see rev 1.1, solved -%%% problem with MakeUppercase and MakeLowercase pointed -%%% out by Marco Feuerstein (2007-06-06) - - -%%% Last modified Jul. 2007 - -\NeedsTeXFormat{LaTeX2e}[1995/12/01] -\ProvidesPackage{fncychap} - [2007/07/30 v1.34 - LaTeX package (Revised chapters)] - -%%%% For conditional inclusion of color -\newif\ifusecolor -\usecolorfalse - - - -%%%% DEFINITION OF Chapapp variables -\newcommand{\CNV}{\huge\bfseries} -\newcommand{\ChNameVar}[1]{\renewcommand{\CNV}{#1}} - - -%%%% DEFINITION OF TheChapter variables -\newcommand{\CNoV}{\huge\bfseries} -\newcommand{\ChNumVar}[1]{\renewcommand{\CNoV}{#1}} - -\newif\ifUCN -\UCNfalse -\newif\ifLCN -\LCNfalse -\def\ChNameLowerCase{\LCNtrue\UCNfalse} -\def\ChNameUpperCase{\UCNtrue\LCNfalse} -\def\ChNameAsIs{\UCNfalse\LCNfalse} - -%%%%% Fix for AMSBook 971008 - -\@ifundefined{@chapapp}{\let\@chapapp\chaptername}{} - - -%%%%% Fix for Bjarne and appendix 980211 - -\newif\ifinapp -\inappfalse -\renewcommand\appendix{\par - \setcounter{chapter}{0}% - \setcounter{section}{0}% - \inapptrue% - \renewcommand\@chapapp{\appendixname}% - \renewcommand\thechapter{\@Alph\c@chapter}} - -%%%%% Fix for frontmatter, mainmatter, and backmatter 040920 - -\@ifundefined{@mainmatter}{\newif\if@mainmatter \@mainmattertrue}{} - -%%%%% - - - -\newcommand{\FmN}[1]{% -\ifUCN - {\MakeUppercase{#1}}\LCNfalse -\else - \ifLCN - {\MakeLowercase{#1}}\UCNfalse - \else #1 - \fi -\fi} - - -%%%% DEFINITION OF Title variables -\newcommand{\CTV}{\Huge\bfseries} -\newcommand{\ChTitleVar}[1]{\renewcommand{\CTV}{#1}} - -%%%% DEFINITION OF the basic rule width -\newlength{\RW} -\setlength{\RW}{1pt} -\newcommand{\ChRuleWidth}[1]{\setlength{\RW}{#1}} - -\newif\ifUCT -\UCTfalse -\newif\ifLCT -\LCTfalse -\def\ChTitleLowerCase{\LCTtrue\UCTfalse} -\def\ChTitleUpperCase{\UCTtrue\LCTfalse} -\def\ChTitleAsIs{\UCTfalse\LCTfalse} -\newcommand{\FmTi}[1]{% -\ifUCT - {\MakeUppercase{#1}}\LCTfalse -\else - \ifLCT - {\MakeLowercase{#1}}\UCTfalse - \else {#1} - \fi -\fi} - - - -\newlength{\mylen} -\newlength{\myhi} -\newlength{\px} -\newlength{\py} -\newlength{\pyy} -\newlength{\pxx} - - -\def\mghrulefill#1{\leavevmode\leaders\hrule\@height #1\hfill\kern\z@} - -\newcommand{\DOCH}{% - \CNV\FmN{\@chapapp}\space \CNoV\thechapter - \par\nobreak - \vskip 20\p@ - } -\newcommand{\DOTI}[1]{% - \CTV\FmTi{#1}\par\nobreak - \vskip 40\p@ - } -\newcommand{\DOTIS}[1]{% - \CTV\FmTi{#1}\par\nobreak - \vskip 40\p@ - } - -%%%%%% SONNY DEF - -\DeclareOption{Sonny}{% - \ChNameVar{\Large\sf} - \ChNumVar{\Huge} - \ChTitleVar{\Large\sf} - \ChRuleWidth{0.5pt} - \ChNameUpperCase - \renewcommand{\DOCH}{% - \raggedleft - \CNV\FmN{\@chapapp}\space \CNoV\thechapter - \par\nobreak - \vskip 40\p@} - \renewcommand{\DOTI}[1]{% - \CTV\raggedleft\mghrulefill{\RW}\par\nobreak - \vskip 5\p@ - \CTV\FmTi{#1}\par\nobreak - \mghrulefill{\RW}\par\nobreak - \vskip 40\p@} - \renewcommand{\DOTIS}[1]{% - \CTV\raggedleft\mghrulefill{\RW}\par\nobreak - \vskip 5\p@ - \CTV\FmTi{#1}\par\nobreak - \mghrulefill{\RW}\par\nobreak - \vskip 40\p@} -} - -%%%%%% LENNY DEF - -\DeclareOption{Lenny}{% - - \ChNameVar{\fontsize{14}{16}\usefont{OT1}{phv}{m}{n}\selectfont} - \ChNumVar{\fontsize{60}{62}\usefont{OT1}{ptm}{m}{n}\selectfont} - \ChTitleVar{\Huge\bfseries\rm} - \ChRuleWidth{1pt} - \renewcommand{\DOCH}{% - \settowidth{\px}{\CNV\FmN{\@chapapp}} - \addtolength{\px}{2pt} - \settoheight{\py}{\CNV\FmN{\@chapapp}} - \addtolength{\py}{1pt} - - \settowidth{\mylen}{\CNV\FmN{\@chapapp}\space\CNoV\thechapter} - \addtolength{\mylen}{1pt} - \settowidth{\pxx}{\CNoV\thechapter} - \addtolength{\pxx}{-1pt} - - \settoheight{\pyy}{\CNoV\thechapter} - \addtolength{\pyy}{-2pt} - \setlength{\myhi}{\pyy} - \addtolength{\myhi}{-1\py} - \par - \parbox[b]{\textwidth}{% - \rule[\py]{\RW}{\myhi}% - \hskip -\RW% - \rule[\pyy]{\px}{\RW}% - \hskip -\px% - \raggedright% - \CNV\FmN{\@chapapp}\space\CNoV\thechapter% - \hskip1pt% - \mghrulefill{\RW}% - \rule{\RW}{\pyy}\par\nobreak% - \vskip -\baselineskip% - \vskip -\pyy% - \hskip \mylen% - \mghrulefill{\RW}\par\nobreak% - \vskip \pyy}% - \vskip 20\p@} - - - \renewcommand{\DOTI}[1]{% - \raggedright - \CTV\FmTi{#1}\par\nobreak - \vskip 40\p@} - - \renewcommand{\DOTIS}[1]{% - \raggedright - \CTV\FmTi{#1}\par\nobreak - \vskip 40\p@} - } - -%%%%%% Peter Osbornes' version of LENNY DEF - -\DeclareOption{PetersLenny}{% - -% five new lengths -\newlength{\bl} % bottom left : orig \space -\setlength{\bl}{6pt} -\newcommand{\BL}[1]{\setlength{\bl}{#1}} -\newlength{\br} % bottom right : orig 1pt -\setlength{\br}{1pt} -\newcommand{\BR}[1]{\setlength{\br}{#1}} -\newlength{\tl} % top left : orig 2pt -\setlength{\tl}{2pt} -\newcommand{\TL}[1]{\setlength{\tl}{#1}} -\newlength{\trr} % top right :orig 1pt -\setlength{\trr}{1pt} -\newcommand{\TR}[1]{\setlength{\trr}{#1}} -\newlength{\blrule} % top right :orig 1pt -\setlength{\trr}{0pt} -\newcommand{\BLrule}[1]{\setlength{\blrule}{#1}} - - - \ChNameVar{\fontsize{14}{16}\usefont{OT1}{phv}{m}{n}\selectfont} - \ChNumVar{\fontsize{60}{62}\usefont{OT1}{ptm}{m}{n}\selectfont} - \ChTitleVar{\Huge\bfseries\rm} - \ChRuleWidth{1pt} -\renewcommand{\DOCH}{% - - -%%%%%%% tweaks for 1--9 and A--Z -\ifcase\c@chapter\relax% -\or\BL{-3pt}\TL{-4pt}\BR{0pt}\TR{-6pt}%1 -\or\BL{0pt}\TL{-4pt}\BR{2pt}\TR{-4pt}%2 -\or\BL{0pt}\TL{-4pt}\BR{2pt}\TR{-4pt}%3 -\or\BL{0pt}\TL{5pt}\BR{2pt}\TR{-4pt}%4 -\or\BL{0pt}\TL{3pt}\BR{2pt}\TR{-4pt}%5 -\or\BL{-1pt}\TL{0pt}\BR{2pt}\TR{-2pt}%6 -\or\BL{0pt}\TL{-3pt}\BR{2pt}\TR{-2pt}%7 -\or\BL{0pt}\TL{-3pt}\BR{2pt}\TR{-2pt}%8 -\or\BL{0pt}\TL{-3pt}\BR{-4pt}\TR{-2pt}%9 -\or\BL{-3pt}\TL{-3pt}\BR{2pt}\TR{-7pt}%10 -\or\BL{-6pt}\TL{-6pt}\BR{0pt}\TR{-9pt}%11 -\or\BL{-6pt}\TL{-6pt}\BR{2pt}\TR{-7pt}%12 -\or\BL{-5pt}\TL{-5pt}\BR{0pt}\TR{-9pt}%13 -\or\BL{-6pt}\TL{-6pt}\BR{0pt}\TR{-9pt}%14 -\or\BL{-3pt}\TL{-3pt}\BR{3pt}\TR{-6pt}%15 -\or\BL{-3pt}\TL{-3pt}\BR{3pt}\TR{-6pt}%16 -\or\BL{-5pt}\TL{-3pt}\BR{-8pt}\TR{-6pt}%17 -\or\BL{-5pt}\TL{-5pt}\BR{0pt}\TR{-9pt}%18 -\or\BL{-3pt}\TL{-3pt}\BR{-6pt}\TR{-9pt}%19 -\or\BL{0pt}\TL{0pt}\BR{0pt}\TR{-5pt}%20 -\fi - -\ifinapp\ifcase\c@chapter\relax% -\or\BL{0pt}\TL{14pt}\BR{5pt}\TR{-19pt}%A -\or\BL{0pt}\TL{-5pt}\BR{-3pt}\TR{-8pt}%B -\or\BL{-3pt}\TL{-2pt}\BR{1pt}\TR{-6pt}\BLrule{0pt}%C -\or\BL{0pt}\TL{-5pt}\BR{-3pt}\TR{-8pt}\BLrule{0pt}%D -\or\BL{0pt}\TL{-5pt}\BR{2pt}\TR{-3pt}%E -\or\BL{0pt}\TL{-5pt}\BR{-10pt}\TR{-1pt}%F -\or\BL{-3pt}\TL{0pt}\BR{0pt}\TR{-7pt}%G -\or\BL{0pt}\TL{-5pt}\BR{3pt}\TR{-1pt}%H -\or\BL{0pt}\TL{-5pt}\BR{3pt}\TR{-1pt}%I -\or\BL{2pt}\TL{0pt}\BR{-3pt}\TR{1pt}%J -\or\BL{0pt}\TL{-5pt}\BR{3pt}\TR{-1pt}%K -\or\BL{0pt}\TL{-5pt}\BR{2pt}\TR{-19pt}%L -\or\BL{0pt}\TL{-5pt}\BR{3pt}\TR{-1pt}%M -\or\BL{0pt}\TL{-5pt}\BR{-2pt}\TR{-1pt}%N -\or\BL{-3pt}\TL{-2pt}\BR{-3pt}\TR{-11pt}%O -\or\BL{0pt}\TL{-5pt}\BR{-9pt}\TR{-3pt}%P -\or\BL{-3pt}\TL{-2pt}\BR{-3pt}\TR{-11pt}%Q -\or\BL{0pt}\TL{-5pt}\BR{4pt}\TR{-8pt}%R -\or\BL{-2pt}\TL{-2pt}\BR{-2pt}\TR{-7pt}%S -\or\BL{-3pt}\TL{0pt}\BR{-5pt}\TR{4pt}\BLrule{8pt}%T -\or\BL{-7pt}\TL{-11pt}\BR{-5pt}\TR{-7pt}\BLrule{0pt}%U -\or\BL{-14pt}\TL{-5pt}\BR{-14pt}\TR{-1pt}\BLrule{14pt}%V -\or\BL{-10pt}\TL{-9pt}\BR{-13pt}\TR{-3pt}\BLrule{7pt}%W -\or\BL{0pt}\TL{-5pt}\BR{3pt}\TR{-1pt}\BLrule{0pt}%X -\or\BL{-6pt}\TL{-4pt}\BR{-7pt}\TR{1pt}\BLrule{7pt}%Y -\or\BL{0pt}\TL{-5pt}\BR{3pt}\TR{-1pt}\BLrule{0pt}%Z -\fi\fi -%%%%%%% - \settowidth{\px}{\CNV\FmN{\@chapapp}} - \addtolength{\px}{\tl} %MOD change 2pt to \tl - \settoheight{\py}{\CNV\FmN{\@chapapp}} - \addtolength{\py}{1pt} - - \settowidth{\mylen}{\CNV\FmN{\@chapapp}\space\CNoV\thechapter} - \addtolength{\mylen}{\trr}% MOD change 1pt to \tr - \settowidth{\pxx}{\CNoV\thechapter} - \addtolength{\pxx}{-1pt} - - \settoheight{\pyy}{\CNoV\thechapter} - \addtolength{\pyy}{-2pt} - \setlength{\myhi}{\pyy} - \addtolength{\myhi}{-1\py} - \par - \parbox[b]{\textwidth}{% - \rule[\py]{\RW}{\myhi}% - \hskip -\RW% - \rule[\pyy]{\px}{\RW}% - \hskip -\px% - \raggedright% - \CNV\FmN{\@chapapp}\rule{\blrule}{\RW}\hskip\bl\CNoV\thechapter%MOD -% \CNV\FmN{\@chapapp}\space\CNoV\thechapter %ORIGINAL - \hskip\br% %MOD 1pt to \br - \mghrulefill{\RW}% - \rule{\RW}{\pyy}\par\nobreak% - \vskip -\baselineskip% - \vskip -\pyy% - \hskip \mylen% - \mghrulefill{\RW}\par\nobreak% - \vskip \pyy}% - \vskip 20\p@} - - - \renewcommand{\DOTI}[1]{% - \raggedright - \CTV\FmTi{#1}\par\nobreak - \vskip 40\p@} - - \renewcommand{\DOTIS}[1]{% - \raggedright - \CTV\FmTi{#1}\par\nobreak - \vskip 40\p@} - } - - -% - - -%%%%%% BJORNSTRUP DEF - -\DeclareOption{Bjornstrup}{% - \usecolortrue - % pzc (Zapf Chancelery) is nice. ppl (Palatino) is cool too. - \ChNumVar{\fontsize{76}{80}\usefont{OT1}{pzc}{m}{n}\selectfont} - \ChTitleVar{\raggedleft\Large\sffamily\bfseries} - - \setlength{\myhi}{10pt} % Space between grey box border and text - \setlength{\mylen}{\textwidth} - \addtolength{\mylen}{-2\myhi} - \renewcommand{\DOCH}{% - \settowidth{\py}{\CNoV\thechapter} - \addtolength{\py}{-10pt} % Amount of space by which the -% % number is shifted right - \fboxsep=0pt% - \colorbox[gray]{.85}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}% - \kern-\py\raise20pt% - \hbox{\color[gray]{.5}\CNoV\thechapter}\\% - } - - \renewcommand{\DOTI}[1]{% - \nointerlineskip\raggedright% - \fboxsep=\myhi% - \vskip-1ex% - \colorbox[gray]{.85}{\parbox[t]{\mylen}{\CTV\FmTi{#1}}}\par\nobreak% - \vskip 40\p@% - } - - \renewcommand{\DOTIS}[1]{% - \fboxsep=0pt - \colorbox[gray]{.85}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}\\% - \nointerlineskip\raggedright% - \fboxsep=\myhi% - \colorbox[gray]{.85}{\parbox[t]{\mylen}{\CTV\FmTi{#1}}}\par\nobreak% - \vskip 40\p@% - } -} - - -%%%%%%% GLENN DEF - - -\DeclareOption{Glenn}{% - \ChNameVar{\bfseries\Large\sf} - \ChNumVar{\Huge} - \ChTitleVar{\bfseries\Large\rm} - \ChRuleWidth{1pt} - \ChNameUpperCase - \ChTitleUpperCase - \renewcommand{\DOCH}{% - \settoheight{\myhi}{\CTV\FmTi{Test}} - \setlength{\py}{\baselineskip} - \addtolength{\py}{\RW} - \addtolength{\py}{\myhi} - \setlength{\pyy}{\py} - \addtolength{\pyy}{-1\RW} - - \raggedright - \CNV\FmN{\@chapapp}\space\CNoV\thechapter - \hskip 3pt\mghrulefill{\RW}\rule[-1\pyy]{2\RW}{\py}\par\nobreak} - - \renewcommand{\DOTI}[1]{% - \addtolength{\pyy}{-4pt} - \settoheight{\myhi}{\CTV\FmTi{#1}} - \addtolength{\myhi}{\py} - \addtolength{\myhi}{-1\RW} - \vskip -1\pyy - \rule{2\RW}{\myhi}\mghrulefill{\RW}\hskip 2pt - \raggedleft\CTV\FmTi{#1}\par\nobreak - \vskip 80\p@} - -\newlength{\backskip} - \renewcommand{\DOTIS}[1]{% -% \setlength{\py}{10pt} -% \setlength{\pyy}{\py} -% \addtolength{\pyy}{\RW} -% \setlength{\myhi}{\baselineskip} -% \addtolength{\myhi}{\pyy} -% \mghrulefill{\RW}\rule[-1\py]{2\RW}{\pyy}\par\nobreak -% \addtolength{}{} -%\vskip -1\baselineskip -% \rule{2\RW}{\myhi}\mghrulefill{\RW}\hskip 2pt -% \raggedleft\CTV\FmTi{#1}\par\nobreak -% \vskip 60\p@} -%% Fix suggested by Tomas Lundberg - \setlength{\py}{25pt} % eller vad man vill - \setlength{\pyy}{\py} - \setlength{\backskip}{\py} - \addtolength{\backskip}{2pt} - \addtolength{\pyy}{\RW} - \setlength{\myhi}{\baselineskip} - \addtolength{\myhi}{\pyy} - \mghrulefill{\RW}\rule[-1\py]{2\RW}{\pyy}\par\nobreak - \vskip -1\backskip - \rule{2\RW}{\myhi}\mghrulefill{\RW}\hskip 3pt % - \raggedleft\CTV\FmTi{#1}\par\nobreak - \vskip 40\p@} - } - -%%%%%%% CONNY DEF - -\DeclareOption{Conny}{% - \ChNameUpperCase - \ChTitleUpperCase - \ChNameVar{\centering\Huge\rm\bfseries} - \ChNumVar{\Huge} - \ChTitleVar{\centering\Huge\rm} - \ChRuleWidth{2pt} - - \renewcommand{\DOCH}{% - \mghrulefill{3\RW}\par\nobreak - \vskip -0.5\baselineskip - \mghrulefill{\RW}\par\nobreak - \CNV\FmN{\@chapapp}\space \CNoV\thechapter - \par\nobreak - \vskip -0.5\baselineskip - } - \renewcommand{\DOTI}[1]{% - \mghrulefill{\RW}\par\nobreak - \CTV\FmTi{#1}\par\nobreak - \vskip 60\p@ - } - \renewcommand{\DOTIS}[1]{% - \mghrulefill{\RW}\par\nobreak - \CTV\FmTi{#1}\par\nobreak - \vskip 60\p@ - } - } - -%%%%%%% REJNE DEF - -\DeclareOption{Rejne}{% - - \ChNameUpperCase - \ChTitleUpperCase - \ChNameVar{\centering\Large\rm} - \ChNumVar{\Huge} - \ChTitleVar{\centering\Huge\rm} - \ChRuleWidth{1pt} - \renewcommand{\DOCH}{% - \settoheight{\py}{\CNoV\thechapter} - \parskip=0pt plus 1pt % Set parskip to default, just in case v1.31 - \addtolength{\py}{-1pt} - \CNV\FmN{\@chapapp}\par\nobreak - \vskip 20\p@ - \setlength{\myhi}{2\baselineskip} - \setlength{\px}{\myhi} - \addtolength{\px}{-1\RW} - \rule[-1\px]{\RW}{\myhi}\mghrulefill{\RW}\hskip - 10pt\raisebox{-0.5\py}{\CNoV\thechapter}\hskip 10pt\mghrulefill{\RW}\rule[-1\px]{\RW}{\myhi}\par\nobreak - \vskip -3\p@% Added -2pt vskip to correct for streched text v1.31 - } - \renewcommand{\DOTI}[1]{% - \setlength{\mylen}{\textwidth} - \parskip=0pt plus 1pt % Set parskip to default, just in case v1.31 - \addtolength{\mylen}{-2\RW} - {\vrule width\RW}\parbox{\mylen}{\CTV\FmTi{#1}}{\vrule width\RW}\par\nobreak% - \vskip -3pt\rule{\RW}{2\baselineskip}\mghrulefill{\RW}\rule{\RW}{2\baselineskip}% - \vskip 60\p@% Added -2pt in vskip to correct for streched text v1.31 - } - \renewcommand{\DOTIS}[1]{% - \setlength{\py}{\fboxrule} - \setlength{\fboxrule}{\RW} - \setlength{\mylen}{\textwidth} - \addtolength{\mylen}{-2\RW} - \fbox{\parbox{\mylen}{\vskip 2\baselineskip\CTV\FmTi{#1}\par\nobreak\vskip \baselineskip}} - \setlength{\fboxrule}{\py} - \vskip 60\p@ - } - } - - -%%%%%%% BJARNE DEF - -\DeclareOption{Bjarne}{% - \ChNameUpperCase - \ChTitleUpperCase - \ChNameVar{\raggedleft\normalsize\rm} - \ChNumVar{\raggedleft \bfseries\Large} - \ChTitleVar{\raggedleft \Large\rm} - \ChRuleWidth{1pt} - - -%% Note thechapter -> c@chapter fix appendix bug -%% Fixed misspelled 12 - - \newcounter{AlphaCnt} - \newcounter{AlphaDecCnt} - \newcommand{\AlphaNo}{% - \ifcase\number\theAlphaCnt - \ifnum\c@chapter=0 - ZERO\else{}\fi - \or ONE\or TWO\or THREE\or FOUR\or FIVE - \or SIX\or SEVEN\or EIGHT\or NINE\or TEN - \or ELEVEN\or TWELVE\or THIRTEEN\or FOURTEEN\or FIFTEEN - \or SIXTEEN\or SEVENTEEN\or EIGHTEEN\or NINETEEN\fi -} - - \newcommand{\AlphaDecNo}{% - \setcounter{AlphaDecCnt}{0} - \@whilenum\number\theAlphaCnt>0\do - {\addtocounter{AlphaCnt}{-10} - \addtocounter{AlphaDecCnt}{1}} - \ifnum\number\theAlphaCnt=0 - \else - \addtocounter{AlphaDecCnt}{-1} - \addtocounter{AlphaCnt}{10} - \fi - - - \ifcase\number\theAlphaDecCnt\or TEN\or TWENTY\or THIRTY\or - FORTY\or FIFTY\or SIXTY\or SEVENTY\or EIGHTY\or NINETY\fi - } - \newcommand{\TheAlphaChapter}{% - - \ifinapp - \thechapter - \else - \setcounter{AlphaCnt}{\c@chapter} - \ifnum\c@chapter<20 - \AlphaNo - \else - \AlphaDecNo\AlphaNo - \fi - \fi - } - \renewcommand{\DOCH}{% - \mghrulefill{\RW}\par\nobreak - \CNV\FmN{\@chapapp}\par\nobreak - \CNoV\TheAlphaChapter\par\nobreak - \vskip -1\baselineskip\vskip 5pt\mghrulefill{\RW}\par\nobreak - \vskip 20\p@ - } - \renewcommand{\DOTI}[1]{% - \CTV\FmTi{#1}\par\nobreak - \vskip 40\p@ - } - \renewcommand{\DOTIS}[1]{% - \CTV\FmTi{#1}\par\nobreak - \vskip 40\p@ - } -} - -\DeclareOption*{% - \PackageWarning{fancychapter}{unknown style option} - } - -\ProcessOptions* \relax - -\ifusecolor - \RequirePackage{color} -\fi -\def\@makechapterhead#1{% - \vspace*{50\p@}% - {\parindent \z@ \raggedright \normalfont - \ifnum \c@secnumdepth >\m@ne - \if@mainmatter%%%%% Fix for frontmatter, mainmatter, and backmatter 040920 - \DOCH - \fi - \fi - \interlinepenalty\@M - \if@mainmatter%%%%% Fix for frontmatter, mainmatter, and backmatter 060424 - \DOTI{#1}% - \else% - \DOTIS{#1}% - \fi - }} - - -%%% Begin: To avoid problem with scrbook.cls (fncychap version 1.32) - -%%OUT: -%\def\@schapter#1{\if@twocolumn -% \@topnewpage[\@makeschapterhead{#1}]% -% \else -% \@makeschapterhead{#1}% -% \@afterheading -% \fi} - -%%IN: -\def\@schapter#1{% -\if@twocolumn% - \@makeschapterhead{#1}% -\else% - \@makeschapterhead{#1}% - \@afterheading% -\fi} - -%%% End: To avoid problem with scrbook.cls (fncychap version 1.32) - -\def\@makeschapterhead#1{% - \vspace*{50\p@}% - {\parindent \z@ \raggedright - \normalfont - \interlinepenalty\@M - \DOTIS{#1} - \vskip 40\p@ - }} - -\endinput - - diff --git a/nbconvert/templates/latex/sphinx.sty b/nbconvert/templates/latex/sphinx.sty deleted file mode 100644 index ce15591..0000000 --- a/nbconvert/templates/latex/sphinx.sty +++ /dev/null @@ -1,542 +0,0 @@ -% -% sphinx.sty -% -% Adapted from the old python.sty, mostly written by Fred Drake, -% by Georg Brandl. -% - -\NeedsTeXFormat{LaTeX2e}[1995/12/01] -\ProvidesPackage{sphinx}[2010/01/15 LaTeX package (Sphinx markup)] - -\@ifclassloaded{memoir}{}{\RequirePackage{fancyhdr}} - -\RequirePackage{textcomp} -\RequirePackage{fancybox} -\RequirePackage{titlesec} -\RequirePackage{tabulary} -\RequirePackage{amsmath} % for \text -\RequirePackage{makeidx} -\RequirePackage{framed} -\RequirePackage{ifthen} -\RequirePackage{color} -% For highlighted code. -\RequirePackage{fancyvrb} -% For table captions. -\RequirePackage{threeparttable} -% Handle footnotes in tables. -\RequirePackage{footnote} -\makesavenoteenv{tabulary} -% For floating figures in the text. -\RequirePackage{wrapfig} -% Separate paragraphs by space by default. -\RequirePackage{parskip} - -% Redefine these colors to your liking in the preamble. -\definecolor{TitleColor}{rgb}{0.126,0.263,0.361} -\definecolor{InnerLinkColor}{rgb}{0.208,0.374,0.486} -\definecolor{OuterLinkColor}{rgb}{0.216,0.439,0.388} -% Redefine these colors to something not white if you want to have colored -% background and border for code examples. -\definecolor{VerbatimColor}{rgb}{1,1,1} -\definecolor{VerbatimBorderColor}{rgb}{1,1,1} - -% Uncomment these two lines to ignore the paper size and make the page -% size more like a typical published manual. -%\renewcommand{\paperheight}{9in} -%\renewcommand{\paperwidth}{8.5in} % typical squarish manual -%\renewcommand{\paperwidth}{7in} % O'Reilly ``Programmming Python'' - -% use pdfoutput for pTeX and dvipdfmx -\ifx\kanjiskip\undefined\else - \ifx\Gin@driver{dvipdfmx.def}\undefined\else - \newcount\pdfoutput\pdfoutput=0 - \fi -\fi - -% For graphicx, check if we are compiling under latex or pdflatex. -\ifx\pdftexversion\undefined - \usepackage{graphicx} -\else - \usepackage[pdftex]{graphicx} -\fi - -% for PDF output, use colors and maximal compression -\newif\ifsphinxpdfoutput\sphinxpdfoutputfalse -\ifx\pdfoutput\undefined\else\ifcase\pdfoutput - \let\py@NormalColor\relax - \let\py@TitleColor\relax -\else - \sphinxpdfoutputtrue - \input{pdfcolor} - \def\py@NormalColor{\color[rgb]{0.0,0.0,0.0}} - \def\py@TitleColor{\color{TitleColor}} - \pdfcompresslevel=9 -\fi\fi - -% XeLaTeX can do colors, too -\ifx\XeTeXrevision\undefined\else - \def\py@NormalColor{\color[rgb]{0.0,0.0,0.0}} - \def\py@TitleColor{\color{TitleColor}} -\fi - -% Increase printable page size (copied from fullpage.sty) -\topmargin 0pt -\advance \topmargin by -\headheight -\advance \topmargin by -\headsep - -% attempt to work a little better for A4 users -\textheight \paperheight -\advance\textheight by -2in - -\oddsidemargin 0pt -\evensidemargin 0pt -%\evensidemargin -.25in % for ``manual size'' documents -\marginparwidth 0.5in - -\textwidth \paperwidth -\advance\textwidth by -2in - - -% Style parameters and macros used by most documents here -\raggedbottom -\sloppy -\hbadness = 5000 % don't print trivial gripes - -\pagestyle{empty} % start this way; change for -\pagenumbering{roman} % ToC & chapters - -% Use this to set the font family for headers and other decor: -\newcommand{\py@HeaderFamily}{\sffamily\bfseries} - -% Redefine the 'normal' header/footer style when using "fancyhdr" package: -\@ifundefined{fancyhf}{}{ - % Use \pagestyle{normal} as the primary pagestyle for text. - \fancypagestyle{normal}{ - \fancyhf{} - \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}} - \fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\rightmark}}} - \fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}} - \fancyhead[LE,RO]{{\py@HeaderFamily \@title, \py@release}} - \renewcommand{\headrulewidth}{0.4pt} - \renewcommand{\footrulewidth}{0.4pt} - % define chaptermark with \@chappos when \@chappos is available for Japanese - \ifx\@chappos\undefined\else - \def\chaptermark##1{\markboth{\@chapapp\space\thechapter\space\@chappos\space ##1}{}} - \fi - } - % Update the plain style so we get the page number & footer line, - % but not a chapter or section title. This is to keep the first - % page of a chapter and the blank page between chapters `clean.' - \fancypagestyle{plain}{ - \fancyhf{} - \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}} - \renewcommand{\headrulewidth}{0pt} - \renewcommand{\footrulewidth}{0.4pt} - } -} - -% Some custom font markup commands. -% -\newcommand{\strong}[1]{{\textbf{#1}}} -\newcommand{\code}[1]{\texttt{#1}} -\newcommand{\bfcode}[1]{\code{\bfseries#1}} -\newcommand{\email}[1]{\textsf{#1}} - -% Redefine the Verbatim environment to allow border and background colors. -% The original environment is still used for verbatims within tables. -\let\OriginalVerbatim=\Verbatim -\let\endOriginalVerbatim=\endVerbatim - -% Play with vspace to be able to keep the indentation. -\newlength\distancetoright -\def\mycolorbox#1{% - \setlength\distancetoright{\linewidth}% - \advance\distancetoright -\@totalleftmargin % - \fcolorbox{VerbatimBorderColor}{VerbatimColor}{% - \begin{minipage}{\distancetoright}% - #1 - \end{minipage}% - }% -} -\def\FrameCommand{\mycolorbox} - -\renewcommand{\Verbatim}[1][1]{% - % list starts new par, but we don't want it to be set apart vertically - \bgroup\parskip=0pt% - \smallskip% - % The list environement is needed to control perfectly the vertical - % space. - \list{}{% - \setlength\parskip{0pt}% - \setlength\itemsep{0ex}% - \setlength\topsep{0ex}% - \setlength\partopsep{0pt}% - \setlength\leftmargin{0pt}% - }% - \item\MakeFramed {\FrameRestore}% - \small% - \OriginalVerbatim[#1]% -} -\renewcommand{\endVerbatim}{% - \endOriginalVerbatim% - \endMakeFramed% - \endlist% - % close group to restore \parskip - \egroup% -} - - -% \moduleauthor{name}{email} -\newcommand{\moduleauthor}[2]{} - -% \sectionauthor{name}{email} -\newcommand{\sectionauthor}[2]{} - -% Augment the sectioning commands used to get our own font family in place, -% and reset some internal data items: -\titleformat{\section}{\Large\py@HeaderFamily}% - {\py@TitleColor\thesection}{0.5em}{\py@TitleColor}{\py@NormalColor} -\titleformat{\subsection}{\large\py@HeaderFamily}% - {\py@TitleColor\thesubsection}{0.5em}{\py@TitleColor}{\py@NormalColor} -\titleformat{\subsubsection}{\py@HeaderFamily}% - {\py@TitleColor\thesubsubsection}{0.5em}{\py@TitleColor}{\py@NormalColor} -\titleformat{\paragraph}{\small\py@HeaderFamily}% - {\py@TitleColor}{0em}{\py@TitleColor}{\py@NormalColor} - -% {fulllineitems} is the main environment for object descriptions. -% -\newcommand{\py@itemnewline}[1]{% - \@tempdima\linewidth% - \advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}% -} - -\newenvironment{fulllineitems}{ - \begin{list}{}{\labelwidth \leftmargin \labelsep 0pt - \rightmargin 0pt \topsep -\parskip \partopsep \parskip - \itemsep -\parsep - \let\makelabel=\py@itemnewline} -}{\end{list}} - -% \optional is used for ``[, arg]``, i.e. desc_optional nodes. -\newcommand{\optional}[1]{% - {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}} - -\newlength{\py@argswidth} -\newcommand{\py@sigparams}[2]{% - \parbox[t]{\py@argswidth}{#1\code{)}#2}} -\newcommand{\pysigline}[1]{\item[#1]\nopagebreak} -\newcommand{\pysiglinewithargsret}[3]{% - \settowidth{\py@argswidth}{#1\code{(}}% - \addtolength{\py@argswidth}{-2\py@argswidth}% - \addtolength{\py@argswidth}{\linewidth}% - \item[#1\code{(}\py@sigparams{#2}{#3}]} - -% Production lists -% -\newenvironment{productionlist}{ -% \def\optional##1{{\Large[}##1{\Large]}} - \def\production##1##2{\\\code{##1}&::=&\code{##2}} - \def\productioncont##1{\\& &\code{##1}} - \parindent=2em - \indent - \begin{tabular}{lcl} -}{% - \end{tabular} -} - -% Notices / Admonitions -% -\newlength{\py@noticelength} - -\newcommand{\py@heavybox}{ - \setlength{\fboxrule}{1pt} - \setlength{\fboxsep}{6pt} - \setlength{\py@noticelength}{\linewidth} - \addtolength{\py@noticelength}{-2\fboxsep} - \addtolength{\py@noticelength}{-2\fboxrule} - %\setlength{\shadowsize}{3pt} - \noindent\Sbox - \minipage{\py@noticelength} -} -\newcommand{\py@endheavybox}{ - \endminipage - \endSbox - \fbox{\TheSbox} -} - -\newcommand{\py@lightbox}{{% - \setlength\parskip{0pt}\par - \noindent\rule[0ex]{\linewidth}{0.5pt}% - \par\noindent\vspace{-0.5ex}% - }} -\newcommand{\py@endlightbox}{{% - \setlength{\parskip}{0pt}% - \par\noindent\rule[0.5ex]{\linewidth}{0.5pt}% - \par\vspace{-0.5ex}% - }} - -% Some are quite plain: -\newcommand{\py@noticestart@note}{\py@lightbox} -\newcommand{\py@noticeend@note}{\py@endlightbox} -\newcommand{\py@noticestart@hint}{\py@lightbox} -\newcommand{\py@noticeend@hint}{\py@endlightbox} -\newcommand{\py@noticestart@important}{\py@lightbox} -\newcommand{\py@noticeend@important}{\py@endlightbox} -\newcommand{\py@noticestart@tip}{\py@lightbox} -\newcommand{\py@noticeend@tip}{\py@endlightbox} - -% Others gets more visible distinction: -\newcommand{\py@noticestart@warning}{\py@heavybox} -\newcommand{\py@noticeend@warning}{\py@endheavybox} -\newcommand{\py@noticestart@caution}{\py@heavybox} -\newcommand{\py@noticeend@caution}{\py@endheavybox} -\newcommand{\py@noticestart@attention}{\py@heavybox} -\newcommand{\py@noticeend@attention}{\py@endheavybox} -\newcommand{\py@noticestart@danger}{\py@heavybox} -\newcommand{\py@noticeend@danger}{\py@endheavybox} -\newcommand{\py@noticestart@error}{\py@heavybox} -\newcommand{\py@noticeend@error}{\py@endheavybox} - -\newenvironment{notice}[2]{ - \def\py@noticetype{#1} - \csname py@noticestart@#1\endcsname - \strong{#2} -}{\csname py@noticeend@\py@noticetype\endcsname} - -% Allow the release number to be specified independently of the -% \date{}. This allows the date to reflect the document's date and -% release to specify the release that is documented. -% -\newcommand{\py@release}{} -\newcommand{\version}{} -\newcommand{\shortversion}{} -\newcommand{\releaseinfo}{} -\newcommand{\releasename}{Release} -\newcommand{\release}[1]{% - \renewcommand{\py@release}{\releasename\space\version}% - \renewcommand{\version}{#1}} -\newcommand{\setshortversion}[1]{% - \renewcommand{\shortversion}{#1}} -\newcommand{\setreleaseinfo}[1]{% - \renewcommand{\releaseinfo}{#1}} - -% Allow specification of the author's address separately from the -% author's name. This can be used to format them differently, which -% is a good thing. -% -\newcommand{\py@authoraddress}{} -\newcommand{\authoraddress}[1]{\renewcommand{\py@authoraddress}{#1}} - -% This sets up the fancy chapter headings that make the documents look -% at least a little better than the usual LaTeX output. -% -\@ifundefined{ChTitleVar}{}{ - \ChNameVar{\raggedleft\normalsize\py@HeaderFamily} - \ChNumVar{\raggedleft \bfseries\Large\py@HeaderFamily} - \ChTitleVar{\raggedleft \textrm{\Huge\py@HeaderFamily}} - % This creates chapter heads without the leading \vspace*{}: - \def\@makechapterhead#1{% - {\parindent \z@ \raggedright \normalfont - \ifnum \c@secnumdepth >\m@ne - \DOCH - \fi - \interlinepenalty\@M - \DOTI{#1} - } - } -} - -% Redefine description environment so that it is usable inside fulllineitems. -% -\renewcommand{\description}{% - \list{}{\labelwidth\z@% - \itemindent-\leftmargin% - \labelsep5pt% - \let\makelabel=\descriptionlabel}} - -% Definition lists; requested by AMK for HOWTO documents. Probably useful -% elsewhere as well, so keep in in the general style support. -% -\newenvironment{definitions}{% - \begin{description}% - \def\term##1{\item[##1]\mbox{}\\*[0mm]} -}{% - \end{description}% -} - -% Tell TeX about pathological hyphenation cases: -\hyphenation{Base-HTTP-Re-quest-Hand-ler} - - -% The following is stuff copied from docutils' latex writer. -% -\newcommand{\optionlistlabel}[1]{\bf #1 \hfill} -\newenvironment{optionlist}[1] -{\begin{list}{} - {\setlength{\labelwidth}{#1} - \setlength{\rightmargin}{1cm} - \setlength{\leftmargin}{\rightmargin} - \addtolength{\leftmargin}{\labelwidth} - \addtolength{\leftmargin}{\labelsep} - \renewcommand{\makelabel}{\optionlistlabel}} -}{\end{list}} - -\newlength{\lineblockindentation} -\setlength{\lineblockindentation}{2.5em} -\newenvironment{lineblock}[1] -{\begin{list}{} - {\setlength{\partopsep}{\parskip} - \addtolength{\partopsep}{\baselineskip} - \topsep0pt\itemsep0.15\baselineskip\parsep0pt - \leftmargin#1} - \raggedright} -{\end{list}} - -% Redefine includgraphics for avoiding images larger than the screen size -% If the size is not specified. -\let\py@Oldincludegraphics\includegraphics - -\newbox\image@box% -\newdimen\image@width% -\renewcommand\includegraphics[2][\@empty]{% - \ifx#1\@empty% - \setbox\image@box=\hbox{\py@Oldincludegraphics{#2}}% - \image@width\wd\image@box% - \ifdim \image@width>\linewidth% - \setbox\image@box=\hbox{\py@Oldincludegraphics[width=\linewidth]{#2}}% - \box\image@box% - \else% - \py@Oldincludegraphics{#2}% - \fi% - \else% - \py@Oldincludegraphics[#1]{#2}% - \fi% -} - - -% Fix the index environment to add an entry to the Table of -% Contents; this is much nicer than just having to jump to the end of the book -% and flip around, especially with multiple indexes. -% The memoir class already does this, so we don't duplicate it in that case. -% -% A similiar fix must be done to the bibliography environment, although -% dependant on document class. In particular, the '\addcontentsline' command -% should use 'chapter' for a report and 'section' for an article. -% See sphinxmanual.cls and sphinxhowto.cls for specific fixes. -% -\@ifclassloaded{memoir}{}{ - \let\py@OldTheindex=\theindex - \renewcommand{\theindex}{ - \cleardoublepage - \phantomsection - \py@OldTheindex - \addcontentsline{toc}{chapter}{\indexname} - } -} - -% to make pdf with correct encoded bookmarks in Japanese -% this should precede the hyperref package -\ifx\kanjiskip\undefined\else - \usepackage{atbegshi} - \ifx\ucs\undefined - \ifnum 42146=\euc"A4A2 - \AtBeginShipoutFirst{\special{pdf:tounicode EUC-UCS2}} - \else - \AtBeginShipoutFirst{\special{pdf:tounicode 90ms-RKSJ-UCS2}} - \fi - \else - \AtBeginShipoutFirst{\special{pdf:tounicode UTF8-UCS2}} - \fi -\fi - -% Include hyperref last. -\RequirePackage[colorlinks,breaklinks, - linkcolor=InnerLinkColor,filecolor=OuterLinkColor, - menucolor=OuterLinkColor,urlcolor=OuterLinkColor, - citecolor=InnerLinkColor]{hyperref} -% Fix anchor placement for figures with captions. -% (Note: we don't use a package option here; instead, we give an explicit -% \capstart for figures that actually have a caption.) -\RequirePackage{hypcap} - -% From docutils.writers.latex2e -\providecommand{\DUspan}[2]{% - {% group ("span") to limit the scope of styling commands - \@for\node@class@name:=#1\do{% - \ifcsname docutilsrole\node@class@name\endcsname% - \csname docutilsrole\node@class@name\endcsname% - \fi% - }% - {#2}% node content - }% close "span" -} - -\providecommand*{\DUprovidelength}[2]{ - \ifthenelse{\isundefined{#1}}{\newlength{#1}\setlength{#1}{#2}}{} -} - -\DUprovidelength{\DUlineblockindent}{2.5em} -\ifthenelse{\isundefined{\DUlineblock}}{ - \newenvironment{DUlineblock}[1]{% - \list{}{\setlength{\partopsep}{\parskip} - \addtolength{\partopsep}{\baselineskip} - \setlength{\topsep}{0pt} - \setlength{\itemsep}{0.15\baselineskip} - \setlength{\parsep}{0pt} - \setlength{\leftmargin}{#1}} - \raggedright - } - {\endlist} -}{} - - -% From footmisc.sty: allows footnotes in titles -\let\FN@sf@@footnote\footnote -\def\footnote{\ifx\protect\@typeset@protect - \expandafter\FN@sf@@footnote - \else - \expandafter\FN@sf@gobble@opt - \fi -} -\edef\FN@sf@gobble@opt{\noexpand\protect - \expandafter\noexpand\csname FN@sf@gobble@opt \endcsname} -\expandafter\def\csname FN@sf@gobble@opt \endcsname{% - \@ifnextchar[%] - \FN@sf@gobble@twobracket - \@gobble -} -\def\FN@sf@gobble@twobracket[#1]#2{} - -% adjust the margins for footer, -% this works with the jsclasses only (Japanese standard document classes) -\ifx\@jsc@uplatextrue\undefined\else - \hypersetup{setpagesize=false} - \setlength\footskip{2\baselineskip} - \addtolength{\textheight}{-2\baselineskip} -\fi - -% fix the double index and bibliography on the table of contents -% in jsclasses (Japanese standard document classes) -\ifx\@jsc@uplatextrue\undefined\else - \renewcommand{\theindex}{ - \cleardoublepage - \phantomsection - \py@OldTheindex - } - \renewcommand{\thebibliography}[1]{ - \cleardoublepage - \phantomsection - \py@OldThebibliography{1} - } -\fi - -% do not use \@chappos in Appendix in pTeX -\ifx\kanjiskip\undefined\else - \renewcommand{\appendix}{\par - \setcounter{chapter}{0} - \setcounter{section}{0} - \gdef\@chapapp{\appendixname} - \gdef\@chappos{} - \gdef\thechapter{\@Alph\c@chapter} - } -\fi diff --git a/nbconvert/templates/latex/latex_sphinx_base.tplx b/nbconvert/templates/latex/sphinx_base.tplx similarity index 100% rename from nbconvert/templates/latex/latex_sphinx_base.tplx rename to nbconvert/templates/latex/sphinx_base.tplx diff --git a/nbconvert/templates/latex/latex_sphinx_howto.tplx b/nbconvert/templates/latex/sphinx_howto.tplx similarity index 100% rename from nbconvert/templates/latex/latex_sphinx_howto.tplx rename to nbconvert/templates/latex/sphinx_howto.tplx diff --git a/nbconvert/templates/latex/latex_sphinx_manual.tplx b/nbconvert/templates/latex/sphinx_manual.tplx similarity index 100% rename from nbconvert/templates/latex/latex_sphinx_manual.tplx rename to nbconvert/templates/latex/sphinx_manual.tplx diff --git a/nbconvert/templates/latex/sphinxhowto.cls b/nbconvert/templates/latex/sphinxhowto.cls deleted file mode 100644 index 9625870..0000000 --- a/nbconvert/templates/latex/sphinxhowto.cls +++ /dev/null @@ -1,92 +0,0 @@ -% -% sphinxhowto.cls for Sphinx (http://sphinx-doc.org/) -% - -\NeedsTeXFormat{LaTeX2e}[1995/12/01] -\ProvidesClass{sphinxhowto}[2009/06/02 Document class (Sphinx HOWTO)] - -% 'oneside' option overriding the 'twoside' default -\newif\if@oneside -\DeclareOption{oneside}{\@onesidetrue} -% Pass remaining document options to the parent class. -\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\sphinxdocclass}} -\ProcessOptions\relax - -% Default to two-side document -\if@oneside -% nothing to do (oneside is the default) -\else -\PassOptionsToClass{twoside}{\sphinxdocclass} -\fi - -\LoadClass{\sphinxdocclass} - -% Set some sane defaults for section numbering depth and TOC depth. You can -% reset these counters in your preamble. -% -\setcounter{secnumdepth}{2} - -% Change the title page to look a bit better, and fit in with the fncychap -% ``Bjarne'' style a bit better. -% -\renewcommand{\maketitle}{ - \rule{\textwidth}{1pt} - \ifsphinxpdfoutput - \begingroup - % These \defs are required to deal with multi-line authors; it - % changes \\ to ', ' (comma-space), making it pass muster for - % generating document info in the PDF file. - \def\\{, } - \def\and{and } - \pdfinfo{ - /Author (\@author) - /Title (\@title) - } - \endgroup - \fi - \begin{flushright} - \sphinxlogo% - {\rm\Huge\py@HeaderFamily \@title} \par - {\em\large\py@HeaderFamily \py@release\releaseinfo} \par - \vspace{25pt} - {\Large\py@HeaderFamily - \begin{tabular}[t]{c} - \@author - \end{tabular}} \par - \vspace{25pt} - \@date \par - \py@authoraddress \par - \end{flushright} - \@thanks - \setcounter{footnote}{0} - \let\thanks\relax\let\maketitle\relax - %\gdef\@thanks{}\gdef\@author{}\gdef\@title{} -} - -\let\py@OldTableofcontents=\tableofcontents -\renewcommand{\tableofcontents}{ - \begingroup - \parskip = 0mm - \py@OldTableofcontents - \endgroup - \rule{\textwidth}{1pt} - \vspace{12pt} -} - -\@ifundefined{fancyhf}{ - \pagestyle{plain}}{ - \pagestyle{normal}} % start this way; change for -\pagenumbering{arabic} % ToC & chapters - -\thispagestyle{empty} - -% Fix the bibliography environment to add an entry to the Table of -% Contents. -% For an article document class this environment is a section, -% so no page break before it. -\let\py@OldThebibliography=\thebibliography -\renewcommand{\thebibliography}[1]{ - \phantomsection - \py@OldThebibliography{1} - \addcontentsline{toc}{section}{\bibname} -} diff --git a/nbconvert/templates/latex/sphinxmanual.cls b/nbconvert/templates/latex/sphinxmanual.cls deleted file mode 100644 index a04cea5..0000000 --- a/nbconvert/templates/latex/sphinxmanual.cls +++ /dev/null @@ -1,133 +0,0 @@ -% -% sphinxmanual.cls for Sphinx (http://sphinx-doc.org/) -% - -\NeedsTeXFormat{LaTeX2e}[1995/12/01] -\ProvidesClass{sphinxmanual}[2009/06/02 Document class (Sphinx manual)] - -% chapters starting at odd pages (overridden by 'openany' document option) -\PassOptionsToClass{openright}{\sphinxdocclass} - -% 'oneside' option overriding the 'twoside' default -\newif\if@oneside -\DeclareOption{oneside}{\@onesidetrue} -% Pass remaining document options to the parent class. -\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\sphinxdocclass}} -\ProcessOptions\relax - -% Defaults two-side document -\if@oneside -% nothing to do (oneside is the default) -\else -\PassOptionsToClass{twoside}{\sphinxdocclass} -\fi - -\LoadClass{\sphinxdocclass} - -% Set some sane defaults for section numbering depth and TOC depth. You can -% reset these counters in your preamble. -% -\setcounter{secnumdepth}{2} -\setcounter{tocdepth}{1} - -% Change the title page to look a bit better, and fit in with the fncychap -% ``Bjarne'' style a bit better. -% -\renewcommand{\maketitle}{% - \begin{titlepage}% - \let\footnotesize\small - \let\footnoterule\relax - \rule{\textwidth}{1pt}% - \ifsphinxpdfoutput - \begingroup - % These \defs are required to deal with multi-line authors; it - % changes \\ to ', ' (comma-space), making it pass muster for - % generating document info in the PDF file. - \def\\{, } - \def\and{and } - \pdfinfo{ - /Author (\@author) - /Title (\@title) - } - \endgroup - \fi - \begin{flushright}% - \sphinxlogo% - {\rm\Huge\py@HeaderFamily \@title \par}% - {\em\LARGE\py@HeaderFamily \py@release\releaseinfo \par} - \vfill - {\LARGE\py@HeaderFamily - \begin{tabular}[t]{c} - \@author - \end{tabular} - \par} - \vfill\vfill - {\large - \@date \par - \vfill - \py@authoraddress \par - }% - \end{flushright}%\par - \@thanks - \end{titlepage}% - \cleardoublepage% - \setcounter{footnote}{0}% - \let\thanks\relax\let\maketitle\relax - %\gdef\@thanks{}\gdef\@author{}\gdef\@title{} -} - - -% Catch the end of the {abstract} environment, but here make sure the abstract -% is followed by a blank page if the 'openright' option is used. -% -\let\py@OldEndAbstract=\endabstract -\renewcommand{\endabstract}{ - \if@openright - \ifodd\value{page} - \typeout{Adding blank page after the abstract.} - \vfil\pagebreak - \fi - \fi - \py@OldEndAbstract -} - -% This wraps the \tableofcontents macro with all the magic to get the spacing -% right and have the right number of pages if the 'openright' option has been -% used. This eliminates a fair amount of crud in the individual document files. -% -\let\py@OldTableofcontents=\tableofcontents -\renewcommand{\tableofcontents}{% - \setcounter{page}{1}% - \pagebreak% - \pagestyle{plain}% - {% - \parskip = 0mm% - \py@OldTableofcontents% - \if@openright% - \ifodd\value{page}% - \typeout{Adding blank page after the table of contents.}% - \pagebreak\hspace{0pt}% - \fi% - \fi% - \cleardoublepage% - }% - \pagenumbering{arabic}% - \@ifundefined{fancyhf}{}{\pagestyle{normal}}% -} - -% This is needed to get the width of the section # area wide enough in the -% library reference. Doing it here keeps it the same for all the manuals. -% -\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.6em}} -\renewcommand*\l@subsection{\@dottedtocline{2}{4.1em}{3.5em}} - -% Fix the bibliography environment to add an entry to the Table of -% Contents. -% For a report document class this environment is a chapter. -\let\py@OldThebibliography=\thebibliography -\renewcommand{\thebibliography}[1]{ - \cleardoublepage - \phantomsection - \py@OldThebibliography{1} - \addcontentsline{toc}{chapter}{\bibname} -} diff --git a/nbconvert/templates/latex/tabulary.sty b/nbconvert/templates/latex/tabulary.sty deleted file mode 100644 index ba83c0a..0000000 --- a/nbconvert/templates/latex/tabulary.sty +++ /dev/null @@ -1,452 +0,0 @@ -%% -%% This is file `tabulary.sty', -%% generated with the docstrip utility. -%% -%% The original source files were: -%% -%% tabulary.dtx (with options: `package') -%% DRAFT VERSION -%% -%% File `tabulary.dtx'. -%% Copyright (C) 1995 1996 2003 David Carlisle -%% This file may be distributed under the terms of the LPPL. -%% See 00readme.txt for details. -%% -\NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{tabulary} - [2007/10/02 v0.9 tabulary package (DPC)] -\RequirePackage{array} -\catcode`\Z=14 -\DeclareOption{debugshow}{\catcode`\Z=9\relax} -\ProcessOptions -\def\arraybackslash{\let\\=\@arraycr} -\def\@finalstrut#1{% - \unskip\ifhmode\nobreak\fi\vrule\@width\z@\@height\z@\@depth\dp#1} -\newcount\TY@count -\def\tabulary{% - \let\TY@final\tabular - \let\endTY@final\endtabular - \TY@tabular} -\def\TY@tabular#1{% - \edef\TY@{\@currenvir}% - {\ifnum0=`}\fi - \@ovxx\TY@linewidth - \@ovyy\TY@tablewidth - \count@\z@ - \@tempswatrue - \@whilesw\if@tempswa\fi{% - \advance\count@\@ne - \expandafter\ifx\csname TY@F\the\count@\endcsname\relax - \@tempswafalse - \else - \expandafter\let\csname TY@SF\the\count@\expandafter\endcsname - \csname TY@F\the\count@\endcsname - \global\expandafter\let\csname TY@F\the\count@\endcsname\relax - \expandafter\let\csname TY@S\the\count@\expandafter\endcsname - \csname TY@\the\count@\endcsname - \fi}% - \global\TY@count\@ne - \TY@width\xdef{0pt}% - \global\TY@tablewidth\z@ - \global\TY@linewidth#1\relax -Z\message{^^J^^JTable^^J% -Z Target Width: \the\TY@linewidth^^J% -Z \string\tabcolsep: \the\tabcolsep\space -Z \string\arrayrulewidth: \the\arrayrulewidth\space -Z \string\doublerulesep: \the\doublerulesep^^J% -Z \string\tymin: \the\tymin\space -Z \string\tymax: \the\tymax^^J}% - \let\@classz\TY@classz - \let\verb\TX@verb - \toks@{}\TY@get@body} -\let\TY@@mkpream\@mkpream -\def\TY@mkpream{% - \def\@addamp{% - \if@firstamp \@firstampfalse \else - \global\advance\TY@count\@ne - \edef\@preamble{\@preamble &}\fi - \TY@width\xdef{0pt}}% - \def\@acol{% - \TY@subwidth\col@sep - \@addtopreamble{\hskip\col@sep}}% - \let\@arrayrule\TY@arrayrule - \let\@classvi\TY@classvi - \def\@classv{\save@decl - \expandafter\NC@ecs\@nextchar\extracolsep{}\extracolsep\@@@ - \sbox\z@{\d@llarbegin\@nextchar\d@llarend}% - \TY@subwidth{\wd\z@}% - \@addtopreamble{\d@llarbegin\the@toks\the\count@\relax\d@llarend}% - \prepnext@tok}% - \global\let\@mkpream\TY@@mkpream - \TY@@mkpream} -\def\TY@arrayrule{% - \TY@subwidth\arrayrulewidth - \@addtopreamble \vline} -\def\TY@classvi{\ifcase \@lastchclass - \@acol \or - \TY@subwidth\doublerulesep - \@addtopreamble{\hskip \doublerulesep}\or - \@acol \or - \@classvii - \fi} -\def\TY@tab{% - \setbox\z@\hbox\bgroup - \let\[$\let\]$% - \let\equation$\let\endequation$% - \col@sep\tabcolsep - \let\d@llarbegin\begingroup\let\d@llarend\endgroup - \let\@mkpream\TY@mkpream - \def\multicolumn##1##2##3{\multispan##1\relax}% - \CT@start\TY@tabarray} -\def\TY@tabarray{\@ifnextchar[{\TY@array}{\@array[t]}} -\def\TY@array[#1]{\@array[t]} -\def\TY@width#1{% - \expandafter#1\csname TY@\the\TY@count\endcsname} -\def\TY@subwidth#1{% - \TY@width\dimen@ - \advance\dimen@-#1\relax - \TY@width\xdef{\the\dimen@}% - \global\advance\TY@linewidth-#1\relax} -\def\endtabulary{% - \gdef\@halignto{}% - \let\TY@footnote\footnote% - \def\footnote{}% prevent footnotes from doing anything - \expandafter\TY@tab\the\toks@ - \crcr\omit - {\xdef\TY@save@row{}% - \loop - \advance\TY@count\m@ne - \ifnum\TY@count>\z@ - \xdef\TY@save@row{\TY@save@row&\omit}% - \repeat}\TY@save@row - \endarray\global\setbox1=\lastbox\setbox0=\vbox{\unvbox1 - \unskip\global\setbox1=\lastbox}\egroup - \dimen@\TY@linewidth - \divide\dimen@\TY@count - \ifdim\dimen@<\tymin - \TY@warn{tymin too large (\the\tymin), resetting to \the\dimen@}% - \tymin\dimen@ - \fi - \setbox\tw@=\hbox{\unhbox\@ne - \loop -\@tempdima=\lastskip -\ifdim\@tempdima>\z@ -Z \message{ecs=\the\@tempdima^^J}% - \global\advance\TY@linewidth-\@tempdima -\fi - \unskip - \setbox\tw@=\lastbox - \ifhbox\tw@ -Z \message{Col \the\TY@count: Initial=\the\wd\tw@\space}% - \ifdim\wd\tw@>\tymax - \wd\tw@\tymax -Z \message{> max\space}% -Z \else -Z \message{ \@spaces\space}% - \fi - \TY@width\dimen@ -Z \message{\the\dimen@\space}% - \advance\dimen@\wd\tw@ -Z \message{Final=\the\dimen@\space}% - \TY@width\xdef{\the\dimen@}% - \ifdim\dimen@<\tymin -Z \message{< tymin}% - \global\advance\TY@linewidth-\dimen@ - \expandafter\xdef\csname TY@F\the\TY@count\endcsname - {\the\dimen@}% - \else - \expandafter\ifx\csname TY@F\the\TY@count\endcsname\z@ -Z \message{***}% - \global\advance\TY@linewidth-\dimen@ - \expandafter\xdef\csname TY@F\the\TY@count\endcsname - {\the\dimen@}% - \else -Z \message{> tymin}% - \global\advance\TY@tablewidth\dimen@ - \global\expandafter\let\csname TY@F\the\TY@count\endcsname - \maxdimen - \fi\fi - \advance\TY@count\m@ne - \repeat}% - \TY@checkmin - \TY@checkmin - \TY@checkmin - \TY@checkmin - \TY@count\z@ - \let\TY@box\TY@box@v - \let\footnote\TY@footnote % restore footnotes - {\expandafter\TY@final\the\toks@\endTY@final}% - \count@\z@ - \@tempswatrue - \@whilesw\if@tempswa\fi{% - \advance\count@\@ne - \expandafter\ifx\csname TY@SF\the\count@\endcsname\relax - \@tempswafalse - \else - \global\expandafter\let\csname TY@F\the\count@\expandafter\endcsname - \csname TY@SF\the\count@\endcsname - \global\expandafter\let\csname TY@\the\count@\expandafter\endcsname - \csname TY@S\the\count@\endcsname - \fi}% - \TY@linewidth\@ovxx - \TY@tablewidth\@ovyy - \ifnum0=`{\fi}} -\def\TY@checkmin{% - \let\TY@checkmin\relax -\ifdim\TY@tablewidth>\z@ - \Gscale@div\TY@ratio\TY@linewidth\TY@tablewidth - \ifdim\TY@tablewidth <\linewidth - \def\TY@ratio{1}% - \fi -\else - \TY@warn{No suitable columns!}% - \def\TY@ratio{1}% -\fi -\count@\z@ -Z \message{^^JLine Width: \the\TY@linewidth, -Z Natural Width: \the\TY@tablewidth, -Z Ratio: \TY@ratio^^J}% -\@tempdima\z@ -\loop -\ifnum\count@<\TY@count -\advance\count@\@ne - \ifdim\csname TY@F\the\count@\endcsname>\tymin - \dimen@\csname TY@\the\count@\endcsname - \dimen@\TY@ratio\dimen@ - \ifdim\dimen@<\tymin -Z \message{Column \the\count@\space ->}% - \global\expandafter\let\csname TY@F\the\count@\endcsname\tymin - \global\advance\TY@linewidth-\tymin - \global\advance\TY@tablewidth-\csname TY@\the\count@\endcsname - \let\TY@checkmin\TY@@checkmin - \else - \expandafter\xdef\csname TY@F\the\count@\endcsname{\the\dimen@}% - \advance\@tempdima\csname TY@F\the\count@\endcsname - \fi - \fi -Z \dimen@\csname TY@F\the\count@\endcsname\message{\the\dimen@, }% -\repeat -Z \message{^^JTotal:\the\@tempdima^^J}% -} -\let\TY@@checkmin\TY@checkmin -\newdimen\TY@linewidth -\def\tyformat{\everypar{{\nobreak\hskip\z@skip}}} -\newdimen\tymin -\tymin=10pt -\newdimen\tymax -\tymax=2\textwidth -\def\@testpach{\@chclass - \ifnum \@lastchclass=6 \@ne \@chnum \@ne \else - \ifnum \@lastchclass=7 5 \else - \ifnum \@lastchclass=8 \tw@ \else - \ifnum \@lastchclass=9 \thr@@ - \else \z@ - \ifnum \@lastchclass = 10 \else - \edef\@nextchar{\expandafter\string\@nextchar}% - \@chnum - \if \@nextchar c\z@ \else - \if \@nextchar l\@ne \else - \if \@nextchar r\tw@ \else - \if \@nextchar C7 \else - \if \@nextchar L8 \else - \if \@nextchar R9 \else - \if \@nextchar J10 \else - \z@ \@chclass - \if\@nextchar |\@ne \else - \if \@nextchar !6 \else - \if \@nextchar @7 \else - \if \@nextchar <8 \else - \if \@nextchar >9 \else - 10 - \@chnum - \if \@nextchar m\thr@@\else - \if \@nextchar p4 \else - \if \@nextchar b5 \else - \z@ \@chclass \z@ \@preamerr \z@ \fi \fi \fi \fi\fi \fi \fi\fi \fi - \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi} -\def\TY@classz{% - \@classx - \@tempcnta\count@ - \ifx\TY@box\TY@box@v - \global\advance\TY@count\@ne - \fi - \let\centering c% - \let\raggedright\noindent - \let\raggedleft\indent - \let\arraybackslash\relax - \prepnext@tok - \ifnum\@chnum<4 - \global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@ - \fi - \ifnum\@chnum=6 - \global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@ - \fi - \@addtopreamble{% - \ifcase\@chnum - \hfil \d@llarbegin\insert@column\d@llarend \hfil \or - \kern\z@ - \d@llarbegin \insert@column \d@llarend \hfil \or - \hfil\kern\z@ \d@llarbegin \insert@column \d@llarend \or - $\vcenter\@startpbox{\@nextchar}\insert@column \@endpbox $\or - \vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or - \vbox \@startpbox{\@nextchar}\insert@column \@endpbox \or - \d@llarbegin \insert@column \d@llarend \or% dubious "s" case - \TY@box\centering\or - \TY@box\raggedright\or - \TY@box\raggedleft\or - \TY@box\relax - \fi}\prepnext@tok} -\def\TY@box#1{% - \ifx\centering#1% - \hfil \d@llarbegin\insert@column\d@llarend \hfil \else - \ifx\raggedright#1% - \kern\z@%<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - \d@llarbegin \insert@column \d@llarend \hfil \else - \ifx\raggedleft#1% - \hfil\kern\z@ \d@llarbegin \insert@column \d@llarend \else - \ifx\relax#1% - \d@llarbegin \insert@column \d@llarend - \fi \fi \fi \fi} -\def\TY@box@v#1{% - \vtop \@startpbox{\csname TY@F\the\TY@count\endcsname}% - #1\arraybackslash\tyformat - \insert@column\@endpbox} -\newdimen\TY@tablewidth -\def\Gscale@div#1#2#3{% - \setlength\dimen@{#3}% - \ifdim\dimen@=\z@ - \PackageError{graphics}{Division by 0}\@eha - \dimen@#2% - \fi - \edef\@tempd{\the\dimen@}% - \setlength\dimen@{#2}% - \count@65536\relax - \ifdim\dimen@<\z@ - \dimen@-\dimen@ - \count@-\count@ - \fi - \loop - \ifdim\dimen@<8192\p@ - \dimen@\tw@\dimen@ - \divide\count@\tw@ - \repeat - \dimen@ii=\@tempd\relax - \divide\dimen@ii\count@ - \divide\dimen@\dimen@ii - \edef#1{\strip@pt\dimen@}} -\long\def\TY@get@body#1\end - {\toks@\expandafter{\the\toks@#1}\TY@find@end} -\def\TY@find@end#1{% - \def\@tempa{#1}% - \ifx\@tempa\TY@\def\@tempa{\end{#1}}\expandafter\@tempa - \else\toks@\expandafter - {\the\toks@\end{#1}}\expandafter\TY@get@body\fi} -\def\TY@warn{% - \PackageWarning{tabulary}} -\catcode`\Z=11 -\AtBeginDocument{ -\@ifpackageloaded{colortbl}{% -\expandafter\def\expandafter\@mkpream\expandafter#\expandafter1% - \expandafter{% - \expandafter\let\expandafter\CT@setup\expandafter\relax - \expandafter\let\expandafter\CT@color\expandafter\relax - \expandafter\let\expandafter\CT@do@color\expandafter\relax - \expandafter\let\expandafter\color\expandafter\relax - \expandafter\let\expandafter\CT@column@color\expandafter\relax - \expandafter\let\expandafter\CT@row@color\expandafter\relax - \@mkpream{#1}} -\let\TY@@mkpream\@mkpream -\def\TY@classz{% - \@classx - \@tempcnta\count@ - \ifx\TY@box\TY@box@v - \global\advance\TY@count\@ne - \fi - \let\centering c% - \let\raggedright\noindent - \let\raggedleft\indent - \let\arraybackslash\relax - \prepnext@tok -\expandafter\CT@extract\the\toks\@tempcnta\columncolor!\@nil - \ifnum\@chnum<4 - \global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@ - \fi - \ifnum\@chnum=6 - \global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@ - \fi - \@addtopreamble{% - \setbox\z@\hbox\bgroup\bgroup - \ifcase\@chnum - \hskip\stretch{.5}\kern\z@ - \d@llarbegin\insert@column\d@llarend\hskip\stretch{.5}\or - \kern\z@%<<<<<<<<<<<<<<<<<<<<<<<<<<< - \d@llarbegin \insert@column \d@llarend \hfill \or - \hfill\kern\z@ \d@llarbegin \insert@column \d@llarend \or - $\vcenter\@startpbox{\@nextchar}\insert@column \@endpbox $\or - \vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or - \vbox \@startpbox{\@nextchar}\insert@column \@endpbox \or - \d@llarbegin \insert@column \d@llarend \or% dubious s case - \TY@box\centering\or - \TY@box\raggedright\or - \TY@box\raggedleft\or - \TY@box\relax - \fi - \egroup\egroup -\begingroup - \CT@setup - \CT@column@color - \CT@row@color - \CT@do@color -\endgroup - \@tempdima\ht\z@ - \advance\@tempdima\minrowclearance - \vrule\@height\@tempdima\@width\z@ -\unhbox\z@ -}\prepnext@tok}% - \def\TY@arrayrule{% - \TY@subwidth\arrayrulewidth - \@addtopreamble{{\CT@arc@\vline}}}% - \def\TY@classvi{\ifcase \@lastchclass - \@acol \or - \TY@subwidth\doublerulesep - \ifx\CT@drsc@\relax - \@addtopreamble{\hskip\doublerulesep}% - \else - \@addtopreamble{{\CT@drsc@\vrule\@width\doublerulesep}}% - \fi\or - \@acol \or - \@classvii - \fi}% -}{% -\let\CT@start\relax -} -} -{\uccode`\*=`\ % -\uppercase{\gdef\TX@verb{% - \leavevmode\null\TX@vwarn - {\ifnum0=`}\fi\ttfamily\let\\\ignorespaces - \@ifstar{\let~*\TX@vb}{\TX@vb}}}} -\def\TX@vb#1{\def\@tempa##1#1{\toks@{##1}\edef\@tempa{\the\toks@}% - \expandafter\TX@v\meaning\@tempa\\ \\\ifnum0=`{\fi}}\@tempa!} -\def\TX@v#1!{\afterassignment\TX@vfirst\let\@tempa= } -\begingroup -\catcode`\*=\catcode`\# -\catcode`\#=12 -\gdef\TX@vfirst{% - \if\@tempa#% - \def\@tempb{\TX@v@#}% - \else - \let\@tempb\TX@v@ - \if\@tempa\space~\else\@tempa\fi - \fi - \@tempb} -\gdef\TX@v@*1 *2{% - \TX@v@hash*1##\relax\if*2\\\else~\expandafter\TX@v@\fi*2} -\gdef\TX@v@hash*1##*2{*1\ifx*2\relax\else#\expandafter\TX@v@hash\fi*2} -\endgroup -\def\TX@vwarn{% - \@warning{\noexpand\verb may be unreliable inside tabularx/y}% - \global\let\TX@vwarn\@empty} -\endinput -%% -%% End of file `tabulary.sty'. diff --git a/nbconvert/transformers/activatable.py b/nbconvert/transformers/activatable.py index ad0abfb..80c0eb9 100755 --- a/nbconvert/transformers/activatable.py +++ b/nbconvert/transformers/activatable.py @@ -1,7 +1,7 @@ -from transformers.base import ConfigurableTransformers +from .base import ConfigurableTransformer +from IPython.utils.traitlets import (Bool) - -class ActivatableTransformer(ConfigurableTransformers): +class ActivatableTransformer(ConfigurableTransformer): """A simple ConfigurableTransformers that have an enabled flag Inherit from that if you just want to have a transformer which is diff --git a/nbconvert/transformers/base.py b/nbconvert/transformers/base.py index b5420b0..a25a325 100755 --- a/nbconvert/transformers/base.py +++ b/nbconvert/transformers/base.py @@ -9,11 +9,8 @@ as well as decorator to simplify tasks. from __future__ import print_function, absolute_import from IPython.config.configurable import Configurable -from IPython.utils.traitlets import Unicode, Bool, Dict, List -from .config import GlobalConfigurable - -class ConfigurableTransformers(GlobalConfigurable): +class ConfigurableTransformer(Configurable): """ A configurable transformer Inherit from this class if you wish to have configurability for your @@ -29,7 +26,7 @@ class ConfigurableTransformers(GlobalConfigurable): """ def __init__(self, config=None, **kw): - super(ConfigurableTransformers, self).__init__(config=config, **kw) + super(ConfigurableTransformer, self).__init__(config=config, **kw) def __call__(self, nb, other): """transformation to apply on each notebook. @@ -60,62 +57,3 @@ class ConfigurableTransformers(GlobalConfigurable): raise NotImplementedError('should be implemented by subclass') return cell, other - -def cell_preprocessor(function): - """ wrap a function to be executed on all cells of a notebook - - wrapped function parameters : - cell : the cell - other : external resources - index : index of the cell - """ - def wrappedfunc(nb, other): - for worksheet in nb.worksheets : - for index, cell in enumerate(worksheet.cells): - worksheet.cells[index], other = function(cell, other, index) - return nb, other - return wrappedfunc - - -@cell_preprocessor -def haspyout_transformer(cell, other, count): - """ - Add a haspyout flag to cell that have it - - Easier for templating, where you can't know in advance - wether to write the out prompt - - """ - cell.type = cell.cell_type - cell.haspyout = False - for out in cell.get('outputs', []): - if out.output_type == 'pyout': - cell.haspyout = True - break - return cell, other - -@cell_preprocessor -def coalesce_streams(cell, other, count): - """merge consecutive sequences of stream output into single stream - - to prevent extra newlines inserted at flush calls - - TODO: handle \r deletion - """ - outputs = cell.get('outputs', []) - if not outputs: - return cell, other - new_outputs = [] - last = outputs[0] - new_outputs = [last] - for output in outputs[1:]: - if (output.output_type == 'stream' and - last.output_type == 'stream' and - last.stream == output.stream - ): - last.text += output.text - else: - new_outputs.append(output) - - cell.outputs = new_outputs - return cell, other diff --git a/nbconvert/transformers/coalescestreams.py b/nbconvert/transformers/coalescestreams.py index 6684a2c..b81ba68 100644 --- a/nbconvert/transformers/coalescestreams.py +++ b/nbconvert/transformers/coalescestreams.py @@ -26,7 +26,6 @@ TODO: handle \r deletion outputs = cell.get('outputs', []) if not outputs: return cell, other - new_outputs = [] last = outputs[0] new_outputs = [last] for output in outputs[1:]: diff --git a/nbconvert/transformers/csshtmlheader.py b/nbconvert/transformers/csshtmlheader.py index e746700..31763d4 100755 --- a/nbconvert/transformers/csshtmlheader.py +++ b/nbconvert/transformers/csshtmlheader.py @@ -1,4 +1,4 @@ - +from .activatable import ActivatableTransformer class CSSHtmlHeaderTransformer(ActivatableTransformer): @@ -31,7 +31,6 @@ class CSSHtmlHeaderTransformer(ActivatableTransformer): static = os.path.join(path.get_ipython_package_dir(), 'frontend', 'html', 'notebook', 'static', ) - here = os.path.split(os.path.realpath(__file__))[0] css = os.path.join(static, 'css') for sheet in [ # do we need jquery and prettify? diff --git a/nbconvert/transformers/extractfigure.py b/nbconvert/transformers/extractfigure.py index 5084522..29cfaef 100755 --- a/nbconvert/transformers/extractfigure.py +++ b/nbconvert/transformers/extractfigure.py @@ -1,4 +1,5 @@ - +from IPython.utils.traitlets import (Dict, List, Unicode) +from .activatable import ActivatableTransformer class ExtractFigureTransformer(ActivatableTransformer): @@ -18,6 +19,7 @@ class ExtractFigureTransformer(ActivatableTransformer): config=True, ) + display_data_priority = List(['svg', 'png', 'latex', 'jpg', 'jpeg','text']) #to do change this to .format {} syntax default_key_tpl = Unicode('_fig_{count:02d}.{ext}', config=True) diff --git a/nbconvert/transformers/latex.py b/nbconvert/transformers/latex.py index b6a7294..45d8c08 100755 --- a/nbconvert/transformers/latex.py +++ b/nbconvert/transformers/latex.py @@ -18,7 +18,8 @@ from __future__ import print_function, absolute_import # Our own imports # Needed to override transformer -from .transformers import (ActivatableTransformer) #TODO +from .activatable import (ActivatableTransformer) +from filters import latex #----------------------------------------------------------------------------- # Classes @@ -38,5 +39,5 @@ class LatexTransformer(ActivatableTransformer): """ if hasattr(cell, "source") and cell.cell_type == "markdown": - cell.source = rm_math_space(cell.source) + cell.source = latex.rm_math_space(cell.source) return cell, other diff --git a/nbconvert/transformers/revealhelp.py b/nbconvert/transformers/revealhelp.py index cc34218..76040f2 100755 --- a/nbconvert/transformers/revealhelp.py +++ b/nbconvert/transformers/revealhelp.py @@ -1,6 +1,6 @@ - +from .base import ConfigurableTransformer -class RevealHelpTransformer(ConfigurableTransformers): +class RevealHelpTransformer(ConfigurableTransformer): def __call__(self, nb, other): for worksheet in nb.worksheets : diff --git a/nbconvert/transformers/sphinx.py b/nbconvert/transformers/sphinx.py index 84f9bb4..200fb20 100755 --- a/nbconvert/transformers/sphinx.py +++ b/nbconvert/transformers/sphinx.py @@ -34,7 +34,7 @@ from pygments.formatters import LatexFormatter from IPython.utils.traitlets import Unicode, Bool # Needed to override transformer -from .transformers import (ActivatableTransformer) #TODO +from .activatable import (ActivatableTransformer) #TODO #----------------------------------------------------------------------------- # Classes and functions