Show More
@@ -1,5 +1,5 b'' | |||||
1 | """Utilities for converting notebooks to and from different formats.""" |
|
1 | """Utilities for converting notebooks to and from different formats.""" | |
2 |
|
2 | |||
3 | from .exporters import * |
|
3 | from .exporters import * | |
4 | from .filters import * |
|
4 | import filters | |
5 | from .transformeres import * |
|
5 | import transformers |
@@ -16,16 +16,15 b' Exporter that exports Basic HTML.' | |||||
16 |
|
16 | |||
17 | from IPython.utils.traitlets import Unicode |
|
17 | from IPython.utils.traitlets import Unicode | |
18 |
|
18 | |||
19 | import nbconvert.transformers.csshtmlheader |
|
19 | from ..transformers.csshtmlheader import CSSHtmlHeaderTransformer | |
20 |
|
20 | |||
21 | # local import |
|
21 | from .exporter import Exporter | |
22 | import exporter |
|
|||
23 |
|
22 | |||
24 | #----------------------------------------------------------------------------- |
|
23 | #----------------------------------------------------------------------------- | |
25 | # Classes |
|
24 | # Classes | |
26 | #----------------------------------------------------------------------------- |
|
25 | #----------------------------------------------------------------------------- | |
27 |
|
26 | |||
28 |
class BasicHtmlExporter( |
|
27 | class BasicHtmlExporter(Exporter): | |
29 | """ |
|
28 | """ | |
30 | Exports a basic HTML document. This exporter assists with the export of |
|
29 | Exports a basic HTML document. This exporter assists with the export of | |
31 | HTML. Inherit from it if you are writing your own HTML template and need |
|
30 | HTML. Inherit from it if you are writing your own HTML template and need | |
@@ -52,5 +51,5 b' class BasicHtmlExporter(exporter.Exporter):' | |||||
52 | super(BasicHtmlExporter, self)._register_transformers() |
|
51 | super(BasicHtmlExporter, self)._register_transformers() | |
53 |
|
52 | |||
54 | #Register CSSHtmlHeaderTransformer transformer |
|
53 | #Register CSSHtmlHeaderTransformer transformer | |
55 |
self.register_transformer( |
|
54 | self.register_transformer(CSSHtmlHeaderTransformer) | |
56 |
|
55 |
@@ -22,27 +22,19 b' import os' | |||||
22 | import inspect |
|
22 | import inspect | |
23 | from copy import deepcopy |
|
23 | from copy import deepcopy | |
24 |
|
24 | |||
|
25 | # other libs/dependencies | |||
|
26 | from jinja2 import Environment, FileSystemLoader | |||
|
27 | from markdown import markdown | |||
|
28 | ||||
25 | # IPython imports |
|
29 | # IPython imports | |
26 | from IPython.config.configurable import Configurable |
|
30 | from IPython.config.configurable import Configurable | |
27 | from IPython.config import Config |
|
31 | from IPython.config import Config | |
28 | from IPython.nbformat import current as nbformat |
|
32 | from IPython.nbformat import current as nbformat | |
29 |
from IPython.utils.traitlets import MetaHasTraits, Unicode |
|
33 | from IPython.utils.traitlets import MetaHasTraits, Unicode | |
30 | from IPython.utils.text import indent |
|
34 | from IPython.utils.text import indent | |
31 |
|
35 | |||
32 | # other libs/dependencies |
|
36 | from IPython.nbconvert import filters | |
33 | from jinja2 import Environment, FileSystemLoader |
|
37 | from IPython.nbconvert import transformers | |
34 | from markdown import markdown |
|
|||
35 |
|
||||
36 | # local import |
|
|||
37 | import nbconvert.filters.strings |
|
|||
38 | import nbconvert.filters.markdown |
|
|||
39 | import nbconvert.filters.latex |
|
|||
40 | import nbconvert.filters.datatypefilter |
|
|||
41 | import nbconvert.filters.highlight |
|
|||
42 | import nbconvert.filters.ansi |
|
|||
43 |
|
||||
44 | import nbconvert.transformers.extractfigure |
|
|||
45 | import nbconvert.transformers.coalescestreams |
|
|||
46 |
|
38 | |||
47 | #----------------------------------------------------------------------------- |
|
39 | #----------------------------------------------------------------------------- | |
48 | # Globals and constants |
|
40 | # Globals and constants | |
@@ -54,21 +46,21 b" JINJA_EXTENSIONS = ['jinja2.ext.loopcontrols']" | |||||
54 | default_filters = { |
|
46 | default_filters = { | |
55 | 'indent': indent, |
|
47 | 'indent': indent, | |
56 | 'markdown': markdown, |
|
48 | 'markdown': markdown, | |
57 |
'ansi2html': |
|
49 | 'ansi2html': filters.ansi2html, | |
58 |
'filter_data_type': |
|
50 | 'filter_data_type': filters.DataTypeFilter, | |
59 |
'get_lines': |
|
51 | 'get_lines': filters.get_lines, | |
60 |
'highlight': |
|
52 | 'highlight': filters.highlight, | |
61 |
'highlight2html': |
|
53 | 'highlight2html': filters.highlight, | |
62 |
'highlight2latex': |
|
54 | 'highlight2latex': filters.highlight2latex, | |
63 |
'markdown2latex': |
|
55 | 'markdown2latex': filters.markdown2latex, | |
64 |
'markdown2rst': |
|
56 | 'markdown2rst': filters.markdown2rst, | |
65 |
'pycomment': |
|
57 | 'pycomment': filters.python_comment, | |
66 |
'rm_ansi': |
|
58 | 'rm_ansi': filters.remove_ansi, | |
67 |
'rm_dollars': |
|
59 | 'rm_dollars': filters.strip_dollars, | |
68 |
'rm_fake': |
|
60 | 'rm_fake': filters.rm_fake, | |
69 |
'ansi2latex': |
|
61 | 'ansi2latex': filters.ansi2latex, | |
70 |
'rm_math_space': |
|
62 | 'rm_math_space': filters.rm_math_space, | |
71 |
'wrap': |
|
63 | 'wrap': filters.wrap | |
72 | } |
|
64 | } | |
73 |
|
65 | |||
74 | #----------------------------------------------------------------------------- |
|
66 | #----------------------------------------------------------------------------- | |
@@ -280,11 +272,11 b' class Exporter(Configurable):' | |||||
280 | Register all of the transformers needed for this exporter. |
|
272 | Register all of the transformers needed for this exporter. | |
281 | """ |
|
273 | """ | |
282 |
|
274 | |||
283 |
self.register_transformer( |
|
275 | self.register_transformer(transformers.coalesce_streams) | |
284 |
|
276 | |||
285 | #Remember the figure extraction transformer so it can be enabled and |
|
277 | #Remember the figure extraction transformer so it can be enabled and | |
286 | #disabled easily later. |
|
278 | #disabled easily later. | |
287 |
self.extract_figure_transformer = self.register_transformer( |
|
279 | self.extract_figure_transformer = self.register_transformer(transformers.ExtractFigureTransformer) | |
288 |
|
280 | |||
289 |
|
281 | |||
290 | def _register_filters(self): |
|
282 | def _register_filters(self): |
@@ -16,16 +16,14 b' Exporter for exporting full HTML documents.' | |||||
16 |
|
16 | |||
17 | from IPython.utils.traitlets import Unicode |
|
17 | from IPython.utils.traitlets import Unicode | |
18 |
|
18 | |||
19 | # local import |
|
19 | from .basichtml import BasicHtmlExporter | |
20 | import basichtml |
|
|||
21 |
|
||||
22 | from IPython.config import Config |
|
20 | from IPython.config import Config | |
23 |
|
21 | |||
24 | #----------------------------------------------------------------------------- |
|
22 | #----------------------------------------------------------------------------- | |
25 | # Classes |
|
23 | # Classes | |
26 | #----------------------------------------------------------------------------- |
|
24 | #----------------------------------------------------------------------------- | |
27 |
|
25 | |||
28 |
class FullHtmlExporter( |
|
26 | class FullHtmlExporter(BasicHtmlExporter): | |
29 | """ |
|
27 | """ | |
30 | Exports a full HTML document. |
|
28 | Exports a full HTML document. | |
31 | """ |
|
29 | """ |
@@ -20,19 +20,14 b' tags to circumvent Jinja/Latex syntax conflicts.' | |||||
20 | from IPython.utils.traitlets import Unicode |
|
20 | from IPython.utils.traitlets import Unicode | |
21 | from IPython.config import Config |
|
21 | from IPython.config import Config | |
22 |
|
22 | |||
23 | # other libs/dependencies |
|
23 | from IPython.nbconvert import filters, transformers | |
24 | import nbconvert.filters.latex |
|
24 | from .exporter import Exporter | |
25 | import nbconvert.filters.highlight |
|
|||
26 | from nbconvert.transformers.latex import LatexTransformer |
|
|||
27 |
|
||||
28 | # local import |
|
|||
29 | import exporter |
|
|||
30 |
|
25 | |||
31 | #----------------------------------------------------------------------------- |
|
26 | #----------------------------------------------------------------------------- | |
32 | # Classes and functions |
|
27 | # Classes and functions | |
33 | #----------------------------------------------------------------------------- |
|
28 | #----------------------------------------------------------------------------- | |
34 |
|
29 | |||
35 |
class LatexExporter( |
|
30 | class LatexExporter(Exporter): | |
36 | """ |
|
31 | """ | |
37 | Exports to a Latex template. Inherit from this class if your template is |
|
32 | Exports to a Latex template. Inherit from this class if your template is | |
38 | LaTeX based and you need custom tranformers/filters. Inherit from it if |
|
33 | LaTeX based and you need custom tranformers/filters. Inherit from it if | |
@@ -79,8 +74,8 b' class LatexExporter(exporter.Exporter):' | |||||
79 | super(LatexExporter, self)._register_filters() |
|
74 | super(LatexExporter, self)._register_filters() | |
80 |
|
75 | |||
81 | #Add latex filters to the Jinja2 environment |
|
76 | #Add latex filters to the Jinja2 environment | |
82 |
self.register_filter('escape_tex', |
|
77 | self.register_filter('escape_tex', filters.escape_latex) | |
83 |
self.register_filter('highlight', |
|
78 | self.register_filter('highlight', filters.highlight2latex) | |
84 |
|
79 | |||
85 |
|
80 | |||
86 | def _register_transformers(self): |
|
81 | def _register_transformers(self): | |
@@ -92,7 +87,7 b' class LatexExporter(exporter.Exporter):' | |||||
92 | super(LatexExporter, self)._register_transformers() |
|
87 | super(LatexExporter, self)._register_transformers() | |
93 |
|
88 | |||
94 | #Register latex transformer |
|
89 | #Register latex transformer | |
95 | self.register_transformer(LatexTransformer) |
|
90 | self.register_transformer(transformers.LatexTransformer) | |
96 |
|
91 | |||
97 | @property |
|
92 | @property | |
98 | def default_config(self): |
|
93 | def default_config(self): |
@@ -15,14 +15,13 b' Exporter that will export your ipynb to Markdown.' | |||||
15 |
|
15 | |||
16 | from IPython.utils.traitlets import Unicode |
|
16 | from IPython.utils.traitlets import Unicode | |
17 |
|
17 | |||
18 | # local import |
|
18 | from .exporter import Exporter | |
19 | import exporter |
|
|||
20 |
|
19 | |||
21 | #----------------------------------------------------------------------------- |
|
20 | #----------------------------------------------------------------------------- | |
22 | # Classes |
|
21 | # Classes | |
23 | #----------------------------------------------------------------------------- |
|
22 | #----------------------------------------------------------------------------- | |
24 |
|
23 | |||
25 |
class MarkdownExporter( |
|
24 | class MarkdownExporter(Exporter): | |
26 | """ |
|
25 | """ | |
27 | Exports to a markdown document (.md) |
|
26 | Exports to a markdown document (.md) | |
28 | """ |
|
27 | """ |
@@ -15,14 +15,13 b' Python exporter which exports Notebook code into a PY file.' | |||||
15 |
|
15 | |||
16 | from IPython.utils.traitlets import Unicode |
|
16 | from IPython.utils.traitlets import Unicode | |
17 |
|
17 | |||
18 | # local import |
|
18 | from .exporter import Exporter | |
19 | import exporter |
|
|||
20 |
|
19 | |||
21 | #----------------------------------------------------------------------------- |
|
20 | #----------------------------------------------------------------------------- | |
22 | # Classes |
|
21 | # Classes | |
23 | #----------------------------------------------------------------------------- |
|
22 | #----------------------------------------------------------------------------- | |
24 |
|
23 | |||
25 |
class PythonExporter( |
|
24 | class PythonExporter(Exporter): | |
26 | """ |
|
25 | """ | |
27 | Exports a Python code file. |
|
26 | Exports a Python code file. | |
28 | """ |
|
27 | """ |
@@ -16,14 +16,13 b' Exporter that exports a Python-Armor code file (.py)' | |||||
16 |
|
16 | |||
17 | from IPython.utils.traitlets import Unicode |
|
17 | from IPython.utils.traitlets import Unicode | |
18 |
|
18 | |||
19 | # local import |
|
19 | from .python import PythonExporter | |
20 | import python |
|
|||
21 |
|
20 | |||
22 | #----------------------------------------------------------------------------- |
|
21 | #----------------------------------------------------------------------------- | |
23 | # Classes |
|
22 | # Classes | |
24 | #----------------------------------------------------------------------------- |
|
23 | #----------------------------------------------------------------------------- | |
25 |
|
24 | |||
26 |
class PythonArmorExporter( |
|
25 | class PythonArmorExporter(PythonExporter): | |
27 | """ |
|
26 | """ | |
28 | Exports a Python-Armor code file (.py) |
|
27 | Exports a Python-Armor code file (.py) | |
29 | """ |
|
28 | """ |
@@ -14,18 +14,16 b' Reveal slide show exporter.' | |||||
14 | #----------------------------------------------------------------------------- |
|
14 | #----------------------------------------------------------------------------- | |
15 |
|
15 | |||
16 | from IPython.utils.traitlets import Unicode |
|
16 | from IPython.utils.traitlets import Unicode | |
17 |
|
||||
18 | # local import |
|
|||
19 | import basichtml |
|
|||
20 |
|
||||
21 | import nbconvert.transformers.revealhelp |
|
|||
22 | from IPython.config import Config |
|
17 | from IPython.config import Config | |
23 |
|
18 | |||
|
19 | from .basichtml import BasicHtmlExporter | |||
|
20 | from IPython.nbconvert import transformers | |||
|
21 | ||||
24 | #----------------------------------------------------------------------------- |
|
22 | #----------------------------------------------------------------------------- | |
25 | # Classes |
|
23 | # Classes | |
26 | #----------------------------------------------------------------------------- |
|
24 | #----------------------------------------------------------------------------- | |
27 |
|
25 | |||
28 |
class RevealExporter( |
|
26 | class RevealExporter(BasicHtmlExporter): | |
29 | """ |
|
27 | """ | |
30 | Exports a Reveal slide show (.HTML) which may be rendered in a web browser. |
|
28 | Exports a Reveal slide show (.HTML) which may be rendered in a web browser. | |
31 | """ |
|
29 | """ | |
@@ -47,7 +45,7 b' class RevealExporter(basichtml.BasicHtmlExporter):' | |||||
47 | super(RevealExporter, self)._register_transformers() |
|
45 | super(RevealExporter, self)._register_transformers() | |
48 |
|
46 | |||
49 | #Register reveal help transformer |
|
47 | #Register reveal help transformer | |
50 |
self.register_transformer( |
|
48 | self.register_transformer(transformers.RevealHelpTransformer) | |
51 |
|
49 | |||
52 | @property |
|
50 | @property | |
53 | def default_config(self): |
|
51 | def default_config(self): |
@@ -16,14 +16,13 b' Exporter for exporting notebooks to restructured text.' | |||||
16 | from IPython.utils.traitlets import Unicode |
|
16 | from IPython.utils.traitlets import Unicode | |
17 | from IPython.config import Config |
|
17 | from IPython.config import Config | |
18 |
|
18 | |||
19 | # local import |
|
19 | from .exporter import Exporter | |
20 | import exporter |
|
|||
21 |
|
20 | |||
22 | #----------------------------------------------------------------------------- |
|
21 | #----------------------------------------------------------------------------- | |
23 | # Classes |
|
22 | # Classes | |
24 | #----------------------------------------------------------------------------- |
|
23 | #----------------------------------------------------------------------------- | |
25 |
|
24 | |||
26 |
class RstExporter( |
|
25 | class RstExporter(Exporter): | |
27 | """ |
|
26 | """ | |
28 | Exports restructured text documents. |
|
27 | Exports restructured text documents. | |
29 | """ |
|
28 | """ |
@@ -18,15 +18,15 b' from IPython.utils.traitlets import Unicode' | |||||
18 | from IPython.config import Config |
|
18 | from IPython.config import Config | |
19 |
|
19 | |||
20 | # local import |
|
20 | # local import | |
21 | import latex |
|
21 | from .latex import LatexExporter | |
22 |
|
22 | |||
23 | from nbconvert.transformers.sphinx import SphinxTransformer |
|
23 | from IPython.nbconvert import transformers | |
24 |
|
24 | |||
25 | #----------------------------------------------------------------------------- |
|
25 | #----------------------------------------------------------------------------- | |
26 | # Classes |
|
26 | # Classes | |
27 | #----------------------------------------------------------------------------- |
|
27 | #----------------------------------------------------------------------------- | |
28 |
|
28 | |||
29 |
class SphinxHowtoExporter( |
|
29 | class SphinxHowtoExporter(LatexExporter): | |
30 | """ |
|
30 | """ | |
31 | Exports Sphinx "HowTo" LaTeX documents. The Sphinx "HowTo" exporter |
|
31 | Exports Sphinx "HowTo" LaTeX documents. The Sphinx "HowTo" exporter | |
32 | produces short document format latex for use with PDFLatex. |
|
32 | produces short document format latex for use with PDFLatex. | |
@@ -42,7 +42,7 b' class SphinxHowtoExporter(latex.LatexExporter):' | |||||
42 | super(SphinxHowtoExporter, self)._register_transformers() |
|
42 | super(SphinxHowtoExporter, self)._register_transformers() | |
43 |
|
43 | |||
44 | #Register sphinx latex transformer |
|
44 | #Register sphinx latex transformer | |
45 | self.register_transformer(SphinxTransformer) |
|
45 | self.register_transformer(transformers.SphinxTransformer) | |
46 |
|
46 | |||
47 | @property |
|
47 | @property | |
48 | def default_config(self): |
|
48 | def default_config(self): |
@@ -16,14 +16,13 b' formatted for use with PDFLatex.' | |||||
16 |
|
16 | |||
17 | from IPython.utils.traitlets import Unicode |
|
17 | from IPython.utils.traitlets import Unicode | |
18 |
|
18 | |||
19 | # local import |
|
19 | from .sphinx_howto import SphinxHowtoExporter | |
20 | import sphinx_howto |
|
|||
21 |
|
20 | |||
22 | #----------------------------------------------------------------------------- |
|
21 | #----------------------------------------------------------------------------- | |
23 | # Classes |
|
22 | # Classes | |
24 | #----------------------------------------------------------------------------- |
|
23 | #----------------------------------------------------------------------------- | |
25 |
|
24 | |||
26 |
class SphinxManualExporter( |
|
25 | class SphinxManualExporter(SphinxHowtoExporter): | |
27 | """ |
|
26 | """ | |
28 | Exports Sphinx "Manual" LaTeX documents. The Sphinx "Manual" exporter |
|
27 | Exports Sphinx "Manual" LaTeX documents. The Sphinx "Manual" exporter | |
29 | produces book like latex output for use with PDFLatex. |
|
28 | produces book like latex output for use with PDFLatex. |
@@ -1,5 +1,5 b'' | |||||
1 | from .ansi import * |
|
1 | from .ansi import * | |
2 | from .datatypefilter * |
|
2 | from .datatypefilter import * | |
3 | from .highlight import * |
|
3 | from .highlight import * | |
4 | from .latex import * |
|
4 | from .latex import * | |
5 | from .markdown import * |
|
5 | from .markdown import * |
@@ -131,7 +131,6 b' def ansi2latex(text):' | |||||
131 | outstring = '' |
|
131 | outstring = '' | |
132 | for match in color_pattern.finditer(text): |
|
132 | for match in color_pattern.finditer(text): | |
133 | head = text[last_end:match.start()] |
|
133 | head = text[last_end:match.start()] | |
134 | formater = match.group() |
|
|||
135 | outstring += head |
|
134 | outstring += head | |
136 | if openbrack: |
|
135 | if openbrack: | |
137 | outstring += '}'*openbrack |
|
136 | outstring += '}'*openbrack |
@@ -20,7 +20,7 b' from pygments.formatters import HtmlFormatter' | |||||
20 | from pygments.formatters import LatexFormatter |
|
20 | from pygments.formatters import LatexFormatter | |
21 |
|
21 | |||
22 | # Our own imports |
|
22 | # Our own imports | |
23 | from nbconvert.utils.lexers import IPythonLexer |
|
23 | from IPython.nbconvert.utils.lexers import IPythonLexer | |
24 |
|
24 | |||
25 | #----------------------------------------------------------------------------- |
|
25 | #----------------------------------------------------------------------------- | |
26 | # Globals and constants |
|
26 | # Globals and constants |
@@ -14,10 +14,10 b' templates.' | |||||
14 | #----------------------------------------------------------------------------- |
|
14 | #----------------------------------------------------------------------------- | |
15 | # Imports |
|
15 | # Imports | |
16 | #----------------------------------------------------------------------------- |
|
16 | #----------------------------------------------------------------------------- | |
17 | import re |
|
|||
18 |
|
17 | |||
19 | # Our own imports |
|
18 | # Our own imports | |
20 | import textwrap |
|
19 | import textwrap | |
|
20 | ||||
21 | #----------------------------------------------------------------------------- |
|
21 | #----------------------------------------------------------------------------- | |
22 | # Functions |
|
22 | # Functions | |
23 | #----------------------------------------------------------------------------- |
|
23 | #----------------------------------------------------------------------------- |
@@ -1,10 +1,9 b'' | |||||
1 |
|
||||
2 |
|
|
1 | # Class base Transformers | |
3 | from activatable import ActivatableTransformer |
|
2 | from .activatable import ActivatableTransformer | |
4 | from base import ConfigurableTransformer |
|
3 | from .base import ConfigurableTransformer | |
5 | from extractfigure import ExtractFigureTransformer |
|
4 | from .extractfigure import ExtractFigureTransformer | |
6 | from latex import LatexTransformer |
|
5 | from .latex import LatexTransformer | |
7 | from sphinx import SphinxTransformer |
|
6 | from .sphinx import SphinxTransformer | |
8 |
|
7 | |||
9 | # decorated function Transformers |
|
8 | # decorated function Transformers | |
10 | from coalescestreams import coalesce_streams |
|
9 | from .coalescestreams import coalesce_streams |
@@ -16,9 +16,6 b' It exposes a convenient class to inherit from to access configurability.' | |||||
16 | # Imports |
|
16 | # Imports | |
17 | #----------------------------------------------------------------------------- |
|
17 | #----------------------------------------------------------------------------- | |
18 |
|
18 | |||
19 | from __future__ import print_function, absolute_import |
|
|||
20 |
|
||||
21 | from IPython.config.configurable import Configurable |
|
|||
22 | from ..utils.config import GlobalConfigurable |
|
19 | from ..utils.config import GlobalConfigurable | |
23 |
|
20 | |||
24 | #----------------------------------------------------------------------------- |
|
21 | #----------------------------------------------------------------------------- |
@@ -14,7 +14,7 b" notebook file. The extracted figures are returned in the 'resources' dictionary" | |||||
14 | #----------------------------------------------------------------------------- |
|
14 | #----------------------------------------------------------------------------- | |
15 | import itertools |
|
15 | import itertools | |
16 |
|
16 | |||
17 |
from IPython.utils.traitlets import |
|
17 | from IPython.utils.traitlets import Dict, Unicode | |
18 | from .activatable import ActivatableTransformer |
|
18 | from .activatable import ActivatableTransformer | |
19 |
|
19 | |||
20 | #----------------------------------------------------------------------------- |
|
20 | #----------------------------------------------------------------------------- |
@@ -18,7 +18,7 b' from __future__ import print_function, absolute_import' | |||||
18 | # Our own imports |
|
18 | # Our own imports | |
19 | # Needed to override transformer |
|
19 | # Needed to override transformer | |
20 | from .activatable import (ActivatableTransformer) |
|
20 | from .activatable import (ActivatableTransformer) | |
21 |
from nbconvert |
|
21 | from IPython.nbconvert import filters | |
22 |
|
22 | |||
23 | #----------------------------------------------------------------------------- |
|
23 | #----------------------------------------------------------------------------- | |
24 | # Classes |
|
24 | # Classes | |
@@ -49,5 +49,5 b' class LatexTransformer(ActivatableTransformer):' | |||||
49 | #if spaces exist between the ampersands and the math content. |
|
49 | #if spaces exist between the ampersands and the math content. | |
50 | #See filters.latex.rm_math_space for more information. |
|
50 | #See filters.latex.rm_math_space for more information. | |
51 | if hasattr(cell, "source") and cell.cell_type == "markdown": |
|
51 | if hasattr(cell, "source") and cell.cell_type == "markdown": | |
52 |
cell.source = |
|
52 | cell.source = filters.rm_math_space(cell.source) | |
53 | return cell, resources |
|
53 | return cell, resources |
@@ -35,7 +35,7 b' from IPython.utils.traitlets import Unicode, Bool' | |||||
35 | # Needed to override transformer |
|
35 | # Needed to override transformer | |
36 | from .activatable import (ActivatableTransformer) #TODO |
|
36 | from .activatable import (ActivatableTransformer) #TODO | |
37 |
|
37 | |||
38 |
|
|
38 | from IPython.nbconvert.utils import console | |
39 |
|
39 | |||
40 | #----------------------------------------------------------------------------- |
|
40 | #----------------------------------------------------------------------------- | |
41 | # Classes and functions |
|
41 | # Classes and functions | |
@@ -147,8 +147,8 b' class SphinxTransformer(ActivatableTransformer):' | |||||
147 | resources["sphinx"]["outputstyle"] = self._prompt_output_style() |
|
147 | resources["sphinx"]["outputstyle"] = self._prompt_output_style() | |
148 |
|
148 | |||
149 | # Small options |
|
149 | # Small options | |
150 |
resources["sphinx"]["centeroutput"] = |
|
150 | resources["sphinx"]["centeroutput"] = console.prompt_boolean("Do you want to center the output? (false)", False) | |
151 |
resources["sphinx"]["header"] = |
|
151 | resources["sphinx"]["header"] = console.prompt_boolean("Should a Sphinx document header be used? (true)", True) | |
152 | else: |
|
152 | else: | |
153 |
|
153 | |||
154 | # Try to use the traitlets. |
|
154 | # Try to use the traitlets. | |
@@ -194,14 +194,14 b' class SphinxTransformer(ActivatableTransformer):' | |||||
194 | """ |
|
194 | """ | |
195 | Prompt the user to input an Author name |
|
195 | Prompt the user to input an Author name | |
196 | """ |
|
196 | """ | |
197 |
return |
|
197 | return console.input("Author name: ") | |
198 |
|
198 | |||
199 |
|
199 | |||
200 | def _prompt_version(self): |
|
200 | def _prompt_version(self): | |
201 | """ |
|
201 | """ | |
202 | prompt the user to enter a version number |
|
202 | prompt the user to enter a version number | |
203 | """ |
|
203 | """ | |
204 |
return |
|
204 | return console.input("Version (ie ""1.0.0""): ") | |
205 |
|
205 | |||
206 |
|
206 | |||
207 | def _prompt_release(self): |
|
207 | def _prompt_release(self): | |
@@ -209,7 +209,7 b' class SphinxTransformer(ActivatableTransformer):' | |||||
209 | Prompt the user to input a release name |
|
209 | Prompt the user to input a release name | |
210 | """ |
|
210 | """ | |
211 |
|
211 | |||
212 |
return |
|
212 | return console.input("Release Name (ie ""Rough draft""): ") | |
213 |
|
213 | |||
214 |
|
214 | |||
215 | def _prompt_date(self): |
|
215 | def _prompt_date(self): | |
@@ -218,7 +218,7 b' class SphinxTransformer(ActivatableTransformer):' | |||||
218 | """ |
|
218 | """ | |
219 |
|
219 | |||
220 | default_date = date.today().strftime("%B %-d, %Y") |
|
220 | default_date = date.today().strftime("%B %-d, %Y") | |
221 |
user_date = |
|
221 | user_date = console.input("Date (deafults to \"" + default_date + "\"): ") | |
222 | if len(user_date.strip()) == 0: |
|
222 | if len(user_date.strip()) == 0: | |
223 | user_date = default_date |
|
223 | user_date = default_date | |
224 | return user_date |
|
224 | return user_date | |
@@ -237,7 +237,7 b' class SphinxTransformer(ActivatableTransformer):' | |||||
237 | comments = {1: "(recommended for long code segments)", |
|
237 | comments = {1: "(recommended for long code segments)", | |
238 | 2: "(default)"} |
|
238 | 2: "(default)"} | |
239 |
|
239 | |||
240 |
return |
|
240 | return console.prompt_dictionary(styles, default_style=2, menu_comments=comments) | |
241 |
|
241 | |||
242 |
|
242 | |||
243 | def _prompt_chapter_title_style(self): |
|
243 | def _prompt_chapter_title_style(self): | |
@@ -257,5 +257,5 b' class SphinxTransformer(ActivatableTransformer):' | |||||
257 | comments = {1: "(default)", |
|
257 | comments = {1: "(default)", | |
258 | 6: "(for international documents)"} |
|
258 | 6: "(for international documents)"} | |
259 |
|
259 | |||
260 |
return |
|
260 | return console.prompt_dictionary(styles, menu_comments=comments) | |
261 |
|
261 |
@@ -11,7 +11,7 b'' | |||||
11 | # Imports |
|
11 | # Imports | |
12 | #----------------------------------------------------------------------------- |
|
12 | #----------------------------------------------------------------------------- | |
13 |
|
13 | |||
14 |
from IPython.utils.traitlets import |
|
14 | from IPython.utils.traitlets import List | |
15 | from IPython.config.configurable import Configurable |
|
15 | from IPython.config.configurable import Configurable | |
16 |
|
16 | |||
17 | #----------------------------------------------------------------------------- |
|
17 | #----------------------------------------------------------------------------- |
General Comments 0
You need to be logged in to leave comments.
Login now