##// END OF EJS Templates
Merge pull request #4174 from minrk/markup-templates...
Min RK -
r12461:8c88aec6 merge
parent child Browse files
Show More
@@ -68,7 +68,8 b' default_filters = {'
68 68 'strip_math_space': filters.strip_math_space,
69 69 'wrap_text': filters.wrap_text,
70 70 'escape_latex': filters.escape_latex,
71 'citation2latex': filters.citation2latex
71 'citation2latex': filters.citation2latex,
72 'path2url': filters.path2url,
72 73 }
73 74
74 75 #-----------------------------------------------------------------------------
@@ -13,6 +13,7 b' Exporter that will export your ipynb to Markdown.'
13 13 # Imports
14 14 #-----------------------------------------------------------------------------
15 15
16 from IPython.config import Config
16 17 from IPython.utils.traitlets import Unicode
17 18
18 19 from .exporter import Exporter
@@ -29,3 +30,9 b' class MarkdownExporter(Exporter):'
29 30 file_extension = Unicode(
30 31 'md', config=True,
31 32 help="Extension of the file that should be written to disk")
33
34 @property
35 def default_config(self):
36 c = Config({'ExtractOutputPreprocessor':{'enabled':True}})
37 c.merge(super(MarkdownExporter,self).default_config)
38 return c
@@ -19,6 +19,7 b' templates.'
19 19 import os
20 20 import re
21 21 import textwrap
22 from urllib2 import quote
22 23 from xml.etree import ElementTree
23 24
24 25 from IPython.core.interactiveshell import InteractiveShell
@@ -38,6 +39,7 b' __all__ = ['
38 39 'get_lines',
39 40 'ipython2python',
40 41 'posix_path',
42 'path2url',
41 43 ]
42 44
43 45
@@ -181,3 +183,8 b' def posix_path(path):'
181 183 if os.path.sep != '/':
182 184 return path.replace(os.path.sep, '/')
183 185 return path
186
187 def path2url(path):
188 """Turn a file path into a URL"""
189 parts = path.split(os.path.sep)
190 return '/'.join(quote(part) for part in parts)
@@ -362,7 +362,7 b' Note: For best display, use latex syntax highlighting. =))'
362 362 ((*- endblock -*))
363 363
364 364 ((*- block data_jpg -*))
365 ((( conditionally_center_output(insert_graphics(output.jpg_filename | posix_path)) )))
365 ((( conditionally_center_output(insert_graphics(output.jpeg_filename | posix_path)) )))
366 366 ((*- endblock -*))
367 367
368 368 ((*- block data_svg -*))
@@ -2,19 +2,13 b''
2 2
3 3
4 4 {% block in_prompt %}
5 In[{{ cell.prompt_number if cell.prompt_number else ' ' }}]:
6 5 {% endblock in_prompt %}
7 6
8 7 {% block output_prompt %}
9 {% if cell.haspyout %}
10 Out[{{ cell.prompt_number }}]:
11 {%- endif %}
12 8 {%- endblock output_prompt %}
13 9
14 10 {% block input %}
15 ```
16 {{ cell.input }}
17 ```
11 {{ cell.input | indent(4)}}
18 12 {% endblock input %}
19 13
20 14 {% block pyerr %}
@@ -26,6 +20,7 b' Out[{{ cell.prompt_number }}]:'
26 20 {% endblock traceback_line %}
27 21
28 22 {% block pyout %}
23
29 24 {% block data_priority scoped %}
30 25 {{ super() }}
31 26 {% endblock %}
@@ -36,23 +31,25 b' Out[{{ cell.prompt_number }}]:'
36 31 {% endblock stream %}
37 32
38 33 {% block data_svg %}
39 [!image]({{ output.svg_filename }})
34 ![svg]({{ output.svg_filename | path2url }})
40 35 {% endblock data_svg %}
41 36
42 37 {% block data_png %}
43 [!image]({{ output.png_filename }})
38 ![png]({{ output.png_filename | path2url }})
44 39 {% endblock data_png %}
45 40
46 41 {% block data_jpg %}
47 [!image]({{ output.jpg_filename }})
42 ![jpeg]({{ output.jpeg_filename | path2url }})
48 43 {% endblock data_jpg %}
49 44
50 45 {% block data_latex %}
51 $$
52 46 {{ output.latex }}
53 $$
54 47 {% endblock data_latex %}
55 48
49 {% block data_html scoped %}
50 {{ output.html }}
51 {% endblock data_html %}
52
56 53 {% block data_text scoped %}
57 54 {{ output.text | indent }}
58 55 {% endblock data_text %}
@@ -61,6 +58,7 b' $$'
61 58 {{ cell.source | wrap_text(80) }}
62 59 {% endblock markdowncell %}
63 60
61
64 62 {% block headingcell scoped %}
65 63 {{ '#' * cell.level }} {{ cell.source | replace('\n', ' ') }}
66 64 {% endblock headingcell %}
@@ -2,25 +2,22 b''
2 2
3 3
4 4 {% block in_prompt %}
5
6 In[{{ cell.prompt_number if cell.prompt_number else ' ' }}]:
7
8 .. code:: python
9
10 5 {% endblock in_prompt %}
11 6
12 7 {% block output_prompt %}
13 {% if cell.haspyout -%}
14 Out[{{ cell.prompt_number }}]:
15 {% endif %}
16 8 {% endblock output_prompt %}
17 9
18 10 {% block input %}
11 {%- if not cell.input.isspace() -%}
12 .. code:: python
13
19 14 {{ cell.input | indent}}
15 {%- endif -%}
20 16 {% endblock input %}
21 17
22 18 {% block pyerr %}
23 19 ::
20
24 21 {{ super() }}
25 22 {% endblock pyerr %}
26 23
@@ -49,19 +46,27 b" In[{{ cell.prompt_number if cell.prompt_number else ' ' }}]:"
49 46 {% endblock data_png %}
50 47
51 48 {% block data_jpg %}
52 ..jpg image:: {{ output.jpg_filename }}
49 .. image:: {{ output.jpeg_filename }}
53 50 {% endblock data_jpg %}
54 51
55 52 {% block data_latex %}
56 53 .. math::
57 {{ output.latex | indent }}
54
55 {{ output.latex | strip_dollars | indent }}
58 56 {% endblock data_latex %}
59 57
60 58 {% block data_text scoped %}
61 59 .. parsed-literal::
60
62 61 {{ output.text | indent }}
63 62 {% endblock data_text %}
64 63
64 {% block data_html scoped %}
65 .. raw:: html
66
67 {{ output.html | indent }}
68 {% endblock data_html %}
69
65 70 {% block markdowncell scoped %}
66 71 {{ cell.source | markdown2rst }}
67 72 {% endblock markdowncell %}
General Comments 0
You need to be logged in to leave comments. Login now