##// END OF EJS Templates
Merge pull request #4873 from minrk/ucs-combine...
Thomas Kluyver -
r14786:a6f042a3 merge
parent child Browse files
Show More
@@ -1,223 +1,223 b''
1 ((= Latex base template (must inherit)
1 ((= Latex base template (must inherit)
2 This template builds upon the abstract template, adding common latex output
2 This template builds upon the abstract template, adding common latex output
3 functions. Figures, data_text,
3 functions. Figures, data_text,
4 This template does not define a docclass, the inheriting class must define this.=))
4 This template does not define a docclass, the inheriting class must define this.=))
5
5
6 ((*- extends 'display_priority.tplx' -*))
6 ((*- extends 'display_priority.tplx' -*))
7
7
8 %===============================================================================
8 %===============================================================================
9 % Abstract overrides
9 % Abstract overrides
10 %===============================================================================
10 %===============================================================================
11
11
12 ((* block header *))
12 ((* block header *))
13 ((* block docclass *))((* endblock docclass *))
13 ((* block docclass *))((* endblock docclass *))
14
14
15 ((* block packages *))
15 ((* block packages *))
16 \usepackage{graphicx} % Used to insert images
16 \usepackage{graphicx} % Used to insert images
17 \usepackage{adjustbox} % Used to constrain images to a maximum size
17 \usepackage{adjustbox} % Used to constrain images to a maximum size
18 \usepackage{color} % Allow colors to be defined
18 \usepackage{color} % Allow colors to be defined
19 \usepackage{enumerate} % Needed for markdown enumerations to work
19 \usepackage{enumerate} % Needed for markdown enumerations to work
20 \usepackage{geometry} % Used to adjust the document margins
20 \usepackage{geometry} % Used to adjust the document margins
21 \usepackage{amsmath} % Equations
21 \usepackage{amsmath} % Equations
22 \usepackage{amssymb} % Equations
22 \usepackage{amssymb} % Equations
23 \usepackage[mathletters]{ucs} % Extended unicode (utf-8) support
23 \usepackage[mathletters,combine]{ucs} % Extended unicode (utf-8) support
24 \usepackage[utf8x]{inputenc} % Allow utf-8 characters in the tex document
24 \usepackage[utf8x]{inputenc} % Allow utf-8 characters in the tex document
25 \usepackage{fancyvrb} % verbatim replacement that allows latex
25 \usepackage{fancyvrb} % verbatim replacement that allows latex
26 \usepackage{grffile} % extends the file name processing of package graphics
26 \usepackage{grffile} % extends the file name processing of package graphics
27 % to support a larger range
27 % to support a larger range
28 % The hyperref package gives us a pdf with properly built
28 % The hyperref package gives us a pdf with properly built
29 % internal navigation ('pdf bookmarks' for the table of contents,
29 % internal navigation ('pdf bookmarks' for the table of contents,
30 % internal cross-reference links, web links for URLs, etc.)
30 % internal cross-reference links, web links for URLs, etc.)
31 \usepackage{hyperref}
31 \usepackage{hyperref}
32 \usepackage{longtable} % longtable support required by pandoc >1.10
32 \usepackage{longtable} % longtable support required by pandoc >1.10
33 ((* endblock packages *))
33 ((* endblock packages *))
34
34
35 ((* block definitions *))
35 ((* block definitions *))
36 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
36 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
37 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
37 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
38 \definecolor{darkgreen}{rgb}{.12,.54,.11}
38 \definecolor{darkgreen}{rgb}{.12,.54,.11}
39 \definecolor{myteal}{rgb}{.26, .44, .56}
39 \definecolor{myteal}{rgb}{.26, .44, .56}
40 \definecolor{gray}{gray}{0.45}
40 \definecolor{gray}{gray}{0.45}
41 \definecolor{lightgray}{gray}{.95}
41 \definecolor{lightgray}{gray}{.95}
42 \definecolor{mediumgray}{gray}{.8}
42 \definecolor{mediumgray}{gray}{.8}
43 \definecolor{inputbackground}{rgb}{.95, .95, .85}
43 \definecolor{inputbackground}{rgb}{.95, .95, .85}
44 \definecolor{outputbackground}{rgb}{.95, .95, .95}
44 \definecolor{outputbackground}{rgb}{.95, .95, .95}
45 \definecolor{traceback}{rgb}{1, .95, .95}
45 \definecolor{traceback}{rgb}{1, .95, .95}
46 % ansi colors
46 % ansi colors
47 \definecolor{red}{rgb}{.6,0,0}
47 \definecolor{red}{rgb}{.6,0,0}
48 \definecolor{green}{rgb}{0,.65,0}
48 \definecolor{green}{rgb}{0,.65,0}
49 \definecolor{brown}{rgb}{0.6,0.6,0}
49 \definecolor{brown}{rgb}{0.6,0.6,0}
50 \definecolor{blue}{rgb}{0,.145,.698}
50 \definecolor{blue}{rgb}{0,.145,.698}
51 \definecolor{purple}{rgb}{.698,.145,.698}
51 \definecolor{purple}{rgb}{.698,.145,.698}
52 \definecolor{cyan}{rgb}{0,.698,.698}
52 \definecolor{cyan}{rgb}{0,.698,.698}
53 \definecolor{lightgray}{gray}{0.5}
53 \definecolor{lightgray}{gray}{0.5}
54
54
55 % bright ansi colors
55 % bright ansi colors
56 \definecolor{darkgray}{gray}{0.25}
56 \definecolor{darkgray}{gray}{0.25}
57 \definecolor{lightred}{rgb}{1.0,0.39,0.28}
57 \definecolor{lightred}{rgb}{1.0,0.39,0.28}
58 \definecolor{lightgreen}{rgb}{0.48,0.99,0.0}
58 \definecolor{lightgreen}{rgb}{0.48,0.99,0.0}
59 \definecolor{lightblue}{rgb}{0.53,0.81,0.92}
59 \definecolor{lightblue}{rgb}{0.53,0.81,0.92}
60 \definecolor{lightpurple}{rgb}{0.87,0.63,0.87}
60 \definecolor{lightpurple}{rgb}{0.87,0.63,0.87}
61 \definecolor{lightcyan}{rgb}{0.5,1.0,0.83}
61 \definecolor{lightcyan}{rgb}{0.5,1.0,0.83}
62
62
63 % commands and environments needed by pandoc snippets
63 % commands and environments needed by pandoc snippets
64 % extracted from the output of `pandoc -s`
64 % extracted from the output of `pandoc -s`
65
65
66 \DefineShortVerb[commandchars=\\\{\}]{\|}
66 \DefineShortVerb[commandchars=\\\{\}]{\|}
67 \DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
67 \DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
68 % Add ',fontsize=\small' for more characters per line
68 % Add ',fontsize=\small' for more characters per line
69 \newenvironment{Shaded}{}{}
69 \newenvironment{Shaded}{}{}
70 \newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
70 \newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
71 \newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}}
71 \newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}}
72 \newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
72 \newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
73 \newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
73 \newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
74 \newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
74 \newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
75 \newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
75 \newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
76 \newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
76 \newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
77 \newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}}
77 \newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}}
78 \newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}}
78 \newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}}
79 \newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
79 \newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
80 \newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}}
80 \newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}}
81 \newcommand{\RegionMarkerTok}[1]{{#1}}
81 \newcommand{\RegionMarkerTok}[1]{{#1}}
82 \newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
82 \newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
83 \newcommand{\NormalTok}[1]{{#1}}
83 \newcommand{\NormalTok}[1]{{#1}}
84
84
85 % Define a nice break command that doesn't care if a line doesn't already
85 % Define a nice break command that doesn't care if a line doesn't already
86 % exist.
86 % exist.
87 \def\br{\hspace*{\fill} \\* }
87 \def\br{\hspace*{\fill} \\* }
88 % Math Jax compatability definitions
88 % Math Jax compatability definitions
89 \def\gt{>}
89 \def\gt{>}
90 \def\lt{<}
90 \def\lt{<}
91 % Document parameters
91 % Document parameters
92 ((* block title *))\title{((( resources.metadata.name | escape_latex )))}((* endblock title *))
92 ((* block title *))\title{((( resources.metadata.name | escape_latex )))}((* endblock title *))
93 ((* block date *))((* endblock date *))
93 ((* block date *))((* endblock date *))
94 ((* block author *))((* endblock author *))
94 ((* block author *))((* endblock author *))
95 ((* endblock definitions *))
95 ((* endblock definitions *))
96
96
97 ((* block commands *))
97 ((* block commands *))
98 % Prevent overflowing lines due to hard-to-break entities
98 % Prevent overflowing lines due to hard-to-break entities
99 \sloppy
99 \sloppy
100 % Setup hyperref package
100 % Setup hyperref package
101 \hypersetup{
101 \hypersetup{
102 breaklinks=true, % so long urls are correctly broken across lines
102 breaklinks=true, % so long urls are correctly broken across lines
103 colorlinks=true,
103 colorlinks=true,
104 urlcolor=blue,
104 urlcolor=blue,
105 linkcolor=darkorange,
105 linkcolor=darkorange,
106 citecolor=darkgreen,
106 citecolor=darkgreen,
107 }
107 }
108 % Slightly bigger margins than the latex defaults
108 % Slightly bigger margins than the latex defaults
109 ((* block margins *))
109 ((* block margins *))
110 \geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
110 \geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
111 ((* endblock margins *))
111 ((* endblock margins *))
112 ((* endblock commands *))
112 ((* endblock commands *))
113 ((* endblock header *))
113 ((* endblock header *))
114
114
115 ((* block body *))
115 ((* block body *))
116 \begin{document}
116 \begin{document}
117
117
118 ((* block predoc *))
118 ((* block predoc *))
119 ((* block maketitle *))\maketitle((* endblock maketitle *))
119 ((* block maketitle *))\maketitle((* endblock maketitle *))
120 ((* block abstract *))((* endblock abstract *))
120 ((* block abstract *))((* endblock abstract *))
121 ((* endblock predoc *))
121 ((* endblock predoc *))
122
122
123 ((( super() )))
123 ((( super() )))
124
124
125 % Add a bibliography block to the postdoc
125 % Add a bibliography block to the postdoc
126 ((* block postdoc *))
126 ((* block postdoc *))
127 ((* block bibliography *))((* endblock bibliography *))
127 ((* block bibliography *))((* endblock bibliography *))
128 ((* endblock postdoc *))
128 ((* endblock postdoc *))
129 \end{document}
129 \end{document}
130 ((* endblock body *))
130 ((* endblock body *))
131
131
132 %===============================================================================
132 %===============================================================================
133 % Support blocks
133 % Support blocks
134 %===============================================================================
134 %===============================================================================
135
135
136 % Displaying simple data text
136 % Displaying simple data text
137 ((* block data_text *))
137 ((* block data_text *))
138 \begin{verbatim}
138 \begin{verbatim}
139 ((( output.text )))
139 ((( output.text )))
140 \end{verbatim}
140 \end{verbatim}
141 ((* endblock data_text *))
141 ((* endblock data_text *))
142
142
143 % Display python error text as-is
143 % Display python error text as-is
144 ((* block pyerr *))
144 ((* block pyerr *))
145 \begin{Verbatim}[commandchars=\\\{\}]
145 \begin{Verbatim}[commandchars=\\\{\}]
146 ((( super() )))
146 ((( super() )))
147 \end{Verbatim}
147 \end{Verbatim}
148 ((* endblock pyerr *))
148 ((* endblock pyerr *))
149 ((* block traceback_line *))
149 ((* block traceback_line *))
150 ((( line | indent | strip_ansi | escape_latex )))
150 ((( line | indent | strip_ansi | escape_latex )))
151 ((* endblock traceback_line *))
151 ((* endblock traceback_line *))
152
152
153 % Display stream ouput with coloring
153 % Display stream ouput with coloring
154 ((* block stream *))
154 ((* block stream *))
155 \begin{Verbatim}[commandchars=\\\{\}]
155 \begin{Verbatim}[commandchars=\\\{\}]
156 ((( output.text | escape_latex | ansi2latex )))
156 ((( output.text | escape_latex | ansi2latex )))
157 \end{Verbatim}
157 \end{Verbatim}
158 ((* endblock stream *))
158 ((* endblock stream *))
159
159
160 % Display latex
160 % Display latex
161 ((* block data_latex -*))
161 ((* block data_latex -*))
162 ((*- if output.latex.startswith('$'): -*))
162 ((*- if output.latex.startswith('$'): -*))
163 ((= Replace $ symbols with more explicit, equation block. =))
163 ((= Replace $ symbols with more explicit, equation block. =))
164 \begin{equation*}
164 \begin{equation*}
165 ((( output.latex | strip_dollars )))
165 ((( output.latex | strip_dollars )))
166 \end{equation*}
166 \end{equation*}
167 ((*- else -*))
167 ((*- else -*))
168 ((( output.latex )))
168 ((( output.latex )))
169 ((*- endif *))
169 ((*- endif *))
170 ((* endblock data_latex *))
170 ((* endblock data_latex *))
171
171
172 % Default mechanism for rendering figures
172 % Default mechanism for rendering figures
173 ((*- block data_png -*))((( draw_figure(output.png_filename) )))((*- endblock -*))
173 ((*- block data_png -*))((( draw_figure(output.png_filename) )))((*- endblock -*))
174 ((*- block data_jpg -*))((( draw_figure(output.jpeg_filename) )))((*- endblock -*))
174 ((*- block data_jpg -*))((( draw_figure(output.jpeg_filename) )))((*- endblock -*))
175 ((*- block data_svg -*))((( draw_figure(output.svg_filename) )))((*- endblock -*))
175 ((*- block data_svg -*))((( draw_figure(output.svg_filename) )))((*- endblock -*))
176 ((*- block data_pdf -*))((( draw_figure(output.pdf_filename) )))((*- endblock -*))
176 ((*- block data_pdf -*))((( draw_figure(output.pdf_filename) )))((*- endblock -*))
177
177
178 % Draw a figure using the graphicx package.
178 % Draw a figure using the graphicx package.
179 ((* macro draw_figure(filename) -*))
179 ((* macro draw_figure(filename) -*))
180 ((* set filename = filename | posix_path *))
180 ((* set filename = filename | posix_path *))
181 ((*- block figure scoped -*))
181 ((*- block figure scoped -*))
182 \begin{center}
182 \begin{center}
183 \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{((( filename )))}
183 \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{((( filename )))}
184 \end{center}
184 \end{center}
185 { \hspace*{\fill} \\}
185 { \hspace*{\fill} \\}
186 ((*- endblock figure -*))
186 ((*- endblock figure -*))
187 ((*- endmacro *))
187 ((*- endmacro *))
188
188
189 % Draw heading cell. Explicitly map different cell levels.
189 % Draw heading cell. Explicitly map different cell levels.
190 ((* block headingcell scoped *))
190 ((* block headingcell scoped *))
191
191
192 ((* if cell.level == 1 -*))
192 ((* if cell.level == 1 -*))
193 ((* block h1 -*))\section((* endblock h1 -*))
193 ((* block h1 -*))\section((* endblock h1 -*))
194 ((* elif cell.level == 2 -*))
194 ((* elif cell.level == 2 -*))
195 ((* block h2 -*))\subsection((* endblock h2 -*))
195 ((* block h2 -*))\subsection((* endblock h2 -*))
196 ((* elif cell.level == 3 -*))
196 ((* elif cell.level == 3 -*))
197 ((* block h3 -*))\subsubsection((* endblock h3 -*))
197 ((* block h3 -*))\subsubsection((* endblock h3 -*))
198 ((* elif cell.level == 4 -*))
198 ((* elif cell.level == 4 -*))
199 ((* block h4 -*))\paragraph((* endblock h4 -*))
199 ((* block h4 -*))\paragraph((* endblock h4 -*))
200 ((* elif cell.level == 5 -*))
200 ((* elif cell.level == 5 -*))
201 ((* block h5 -*))\subparagraph((* endblock h5 -*))
201 ((* block h5 -*))\subparagraph((* endblock h5 -*))
202 ((* elif cell.level == 6 -*))
202 ((* elif cell.level == 6 -*))
203 ((* block h6 -*))\\*\textit((* endblock h6 -*))
203 ((* block h6 -*))\\*\textit((* endblock h6 -*))
204 ((*- endif -*))
204 ((*- endif -*))
205 {((( cell.source | replace('\n', ' ') | citation2latex | strip_files_prefix | markdown2latex )))}
205 {((( cell.source | replace('\n', ' ') | citation2latex | strip_files_prefix | markdown2latex )))}
206
206
207 ((* endblock headingcell *))
207 ((* endblock headingcell *))
208
208
209 % Redirect pyout to display data priority.
209 % Redirect pyout to display data priority.
210 ((* block pyout scoped *))
210 ((* block pyout scoped *))
211 ((* block data_priority scoped *))
211 ((* block data_priority scoped *))
212 ((( super() )))
212 ((( super() )))
213 ((* endblock *))
213 ((* endblock *))
214 ((* endblock pyout *))
214 ((* endblock pyout *))
215
215
216 % Render markdown
216 % Render markdown
217 ((* block markdowncell scoped *))
217 ((* block markdowncell scoped *))
218 ((( cell.source | citation2latex | strip_files_prefix | markdown2latex )))
218 ((( cell.source | citation2latex | strip_files_prefix | markdown2latex )))
219 ((* endblock markdowncell *))
219 ((* endblock markdowncell *))
220
220
221 % Don't display unknown types
221 % Don't display unknown types
222 ((* block unknowncell scoped *))
222 ((* block unknowncell scoped *))
223 ((* endblock unknowncell *))
223 ((* endblock unknowncell *))
@@ -1,207 +1,207 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Test NbConvertApp"""
2 """Test NbConvertApp"""
3
3
4 #-----------------------------------------------------------------------------
4 #-----------------------------------------------------------------------------
5 # Copyright (C) 2013 The IPython Development Team
5 # Copyright (C) 2013 The IPython Development Team
6 #
6 #
7 # Distributed under the terms of the BSD License. The full license is in
7 # Distributed under the terms of the BSD License. The full license is in
8 # the file COPYING, distributed as part of this software.
8 # the file COPYING, distributed as part of this software.
9 #-----------------------------------------------------------------------------
9 #-----------------------------------------------------------------------------
10
10
11 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12 # Imports
12 # Imports
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14
14
15 import os
15 import os
16 import glob
16 import glob
17 import sys
17 import sys
18
18
19 from .base import TestsBase
19 from .base import TestsBase
20
20
21 import IPython.testing.tools as tt
21 import IPython.testing.tools as tt
22 from IPython.testing import decorators as dec
22 from IPython.testing import decorators as dec
23
23
24
24
25 #-----------------------------------------------------------------------------
25 #-----------------------------------------------------------------------------
26 # Constants
26 # Constants
27 #-----------------------------------------------------------------------------
27 #-----------------------------------------------------------------------------
28
28
29
29
30 #-----------------------------------------------------------------------------
30 #-----------------------------------------------------------------------------
31 # Classes and functions
31 # Classes and functions
32 #-----------------------------------------------------------------------------
32 #-----------------------------------------------------------------------------
33
33
34 class TestNbConvertApp(TestsBase):
34 class TestNbConvertApp(TestsBase):
35 """Collection of NbConvertApp tests"""
35 """Collection of NbConvertApp tests"""
36
36
37
37
38 def test_notebook_help(self):
38 def test_notebook_help(self):
39 """Will help show if no notebooks are specified?"""
39 """Will help show if no notebooks are specified?"""
40 with self.create_temp_cwd():
40 with self.create_temp_cwd():
41 out, err = self.call('nbconvert --log-level 0', ignore_return_code=True)
41 out, err = self.call('nbconvert --log-level 0', ignore_return_code=True)
42 self.assertIn("see '--help-all'", out)
42 self.assertIn("see '--help-all'", out)
43
43
44 def test_help_output(self):
44 def test_help_output(self):
45 """ipython nbconvert --help-all works"""
45 """ipython nbconvert --help-all works"""
46 tt.help_all_output_test('nbconvert')
46 tt.help_all_output_test('nbconvert')
47
47
48 def test_glob(self):
48 def test_glob(self):
49 """
49 """
50 Do search patterns work for notebook names?
50 Do search patterns work for notebook names?
51 """
51 """
52 with self.create_temp_cwd(['notebook*.ipynb']):
52 with self.create_temp_cwd(['notebook*.ipynb']):
53 self.call('nbconvert --to python *.ipynb --log-level 0')
53 self.call('nbconvert --to python *.ipynb --log-level 0')
54 assert os.path.isfile('notebook1.py')
54 assert os.path.isfile('notebook1.py')
55 assert os.path.isfile('notebook2.py')
55 assert os.path.isfile('notebook2.py')
56
56
57
57
58 def test_glob_subdir(self):
58 def test_glob_subdir(self):
59 """
59 """
60 Do search patterns work for subdirectory notebook names?
60 Do search patterns work for subdirectory notebook names?
61 """
61 """
62 with self.create_temp_cwd():
62 with self.create_temp_cwd():
63 self.copy_files_to(['notebook*.ipynb'], 'subdir/')
63 self.copy_files_to(['notebook*.ipynb'], 'subdir/')
64 self.call('nbconvert --to python --log-level 0 ' +
64 self.call('nbconvert --to python --log-level 0 ' +
65 os.path.join('subdir', '*.ipynb'))
65 os.path.join('subdir', '*.ipynb'))
66 assert os.path.isfile('notebook1.py')
66 assert os.path.isfile('notebook1.py')
67 assert os.path.isfile('notebook2.py')
67 assert os.path.isfile('notebook2.py')
68
68
69
69
70 def test_explicit(self):
70 def test_explicit(self):
71 """
71 """
72 Do explicit notebook names work?
72 Do explicit notebook names work?
73 """
73 """
74 with self.create_temp_cwd(['notebook*.ipynb']):
74 with self.create_temp_cwd(['notebook*.ipynb']):
75 self.call('nbconvert --log-level 0 --to python notebook2')
75 self.call('nbconvert --log-level 0 --to python notebook2')
76 assert not os.path.isfile('notebook1.py')
76 assert not os.path.isfile('notebook1.py')
77 assert os.path.isfile('notebook2.py')
77 assert os.path.isfile('notebook2.py')
78
78
79
79
80 @dec.onlyif_cmds_exist('pdflatex')
80 @dec.onlyif_cmds_exist('pdflatex')
81 @dec.onlyif_cmds_exist('pandoc')
81 @dec.onlyif_cmds_exist('pandoc')
82 def test_filename_spaces(self):
82 def test_filename_spaces(self):
83 """
83 """
84 Generate PDFs with graphics if notebooks have spaces in the name?
84 Generate PDFs with graphics if notebooks have spaces in the name?
85 """
85 """
86 with self.create_temp_cwd(['notebook2.ipynb']):
86 with self.create_temp_cwd(['notebook2.ipynb']):
87 os.rename('notebook2.ipynb', 'notebook with spaces.ipynb')
87 os.rename('notebook2.ipynb', 'notebook with spaces.ipynb')
88 o,e = self.call('nbconvert --log-level 0 --to latex '
88 o,e = self.call('nbconvert --log-level 0 --to latex '
89 '"notebook with spaces" --post PDF '
89 '"notebook with spaces" --post PDF '
90 '--PDFPostProcessor.verbose=True')
90 '--PDFPostProcessor.verbose=True')
91 assert os.path.isfile('notebook with spaces.tex')
91 assert os.path.isfile('notebook with spaces.tex')
92 assert os.path.isdir('notebook with spaces_files')
92 assert os.path.isdir('notebook with spaces_files')
93 assert os.path.isfile('notebook with spaces.pdf')
93 assert os.path.isfile('notebook with spaces.pdf')
94
94
95 @dec.onlyif_cmds_exist('pdflatex')
95 @dec.onlyif_cmds_exist('pdflatex')
96 @dec.onlyif_cmds_exist('pandoc')
96 @dec.onlyif_cmds_exist('pandoc')
97 def test_post_processor(self):
97 def test_post_processor(self):
98 """
98 """
99 Do post processors work?
99 Do post processors work?
100 """
100 """
101 with self.create_temp_cwd(['notebook1.ipynb']):
101 with self.create_temp_cwd(['notebook1.ipynb']):
102 self.call('nbconvert --log-level 0 --to latex notebook1 '
102 self.call('nbconvert --log-level 0 --to latex notebook1 '
103 '--post PDF --PDFPostProcessor.verbose=True')
103 '--post PDF --PDFPostProcessor.verbose=True')
104 assert os.path.isfile('notebook1.tex')
104 assert os.path.isfile('notebook1.tex')
105 assert os.path.isfile('notebook1.pdf')
105 assert os.path.isfile('notebook1.pdf')
106
106
107 @dec.onlyif_cmds_exist('pandoc')
107 @dec.onlyif_cmds_exist('pandoc')
108 def test_spurious_cr(self):
108 def test_spurious_cr(self):
109 """Check for extra CR characters"""
109 """Check for extra CR characters"""
110 with self.create_temp_cwd(['notebook2.ipynb']):
110 with self.create_temp_cwd(['notebook2.ipynb']):
111 self.call('nbconvert --log-level 0 --to latex notebook2')
111 self.call('nbconvert --log-level 0 --to latex notebook2')
112 assert os.path.isfile('notebook2.tex')
112 assert os.path.isfile('notebook2.tex')
113 with open('notebook2.tex') as f:
113 with open('notebook2.tex') as f:
114 tex = f.read()
114 tex = f.read()
115 self.call('nbconvert --log-level 0 --to html notebook2')
115 self.call('nbconvert --log-level 0 --to html notebook2')
116 assert os.path.isfile('notebook2.html')
116 assert os.path.isfile('notebook2.html')
117 with open('notebook2.html') as f:
117 with open('notebook2.html') as f:
118 html = f.read()
118 html = f.read()
119 self.assertEqual(tex.count('\r'), tex.count('\r\n'))
119 self.assertEqual(tex.count('\r'), tex.count('\r\n'))
120 self.assertEqual(html.count('\r'), html.count('\r\n'))
120 self.assertEqual(html.count('\r'), html.count('\r\n'))
121
121
122 @dec.onlyif_cmds_exist('pandoc')
122 @dec.onlyif_cmds_exist('pandoc')
123 def test_png_base64_html_ok(self):
123 def test_png_base64_html_ok(self):
124 """Is embedded png data well formed in HTML?"""
124 """Is embedded png data well formed in HTML?"""
125 with self.create_temp_cwd(['notebook2.ipynb']):
125 with self.create_temp_cwd(['notebook2.ipynb']):
126 self.call('nbconvert --log-level 0 --to HTML '
126 self.call('nbconvert --log-level 0 --to HTML '
127 'notebook2.ipynb --template full')
127 'notebook2.ipynb --template full')
128 assert os.path.isfile('notebook2.html')
128 assert os.path.isfile('notebook2.html')
129 with open('notebook2.html') as f:
129 with open('notebook2.html') as f:
130 assert "data:image/png;base64,b'" not in f.read()
130 assert "data:image/png;base64,b'" not in f.read()
131
131
132 @dec.onlyif_cmds_exist('pandoc')
132 @dec.onlyif_cmds_exist('pandoc')
133 def test_template(self):
133 def test_template(self):
134 """
134 """
135 Do export templates work?
135 Do export templates work?
136 """
136 """
137 with self.create_temp_cwd(['notebook2.ipynb']):
137 with self.create_temp_cwd(['notebook2.ipynb']):
138 self.call('nbconvert --log-level 0 --to slides '
138 self.call('nbconvert --log-level 0 --to slides '
139 'notebook2.ipynb')
139 'notebook2.ipynb')
140 assert os.path.isfile('notebook2.slides.html')
140 assert os.path.isfile('notebook2.slides.html')
141 with open('notebook2.slides.html') as f:
141 with open('notebook2.slides.html') as f:
142 assert '/reveal.css' in f.read()
142 assert '/reveal.css' in f.read()
143
143
144
144
145 def test_glob_explicit(self):
145 def test_glob_explicit(self):
146 """
146 """
147 Can a search pattern be used along with matching explicit notebook names?
147 Can a search pattern be used along with matching explicit notebook names?
148 """
148 """
149 with self.create_temp_cwd(['notebook*.ipynb']):
149 with self.create_temp_cwd(['notebook*.ipynb']):
150 self.call('nbconvert --log-level 0 --to python '
150 self.call('nbconvert --log-level 0 --to python '
151 '*.ipynb notebook1.ipynb notebook2.ipynb')
151 '*.ipynb notebook1.ipynb notebook2.ipynb')
152 assert os.path.isfile('notebook1.py')
152 assert os.path.isfile('notebook1.py')
153 assert os.path.isfile('notebook2.py')
153 assert os.path.isfile('notebook2.py')
154
154
155
155
156 def test_explicit_glob(self):
156 def test_explicit_glob(self):
157 """
157 """
158 Can explicit notebook names be used and then a matching search pattern?
158 Can explicit notebook names be used and then a matching search pattern?
159 """
159 """
160 with self.create_temp_cwd(['notebook*.ipynb']):
160 with self.create_temp_cwd(['notebook*.ipynb']):
161 self.call('nbconvert --log-level 0 --to=python '
161 self.call('nbconvert --log-level 0 --to=python '
162 'notebook1.ipynb notebook2.ipynb *.ipynb')
162 'notebook1.ipynb notebook2.ipynb *.ipynb')
163 assert os.path.isfile('notebook1.py')
163 assert os.path.isfile('notebook1.py')
164 assert os.path.isfile('notebook2.py')
164 assert os.path.isfile('notebook2.py')
165
165
166
166
167 def test_default_config(self):
167 def test_default_config(self):
168 """
168 """
169 Does the default config work?
169 Does the default config work?
170 """
170 """
171 with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py']):
171 with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py']):
172 self.call('nbconvert --log-level 0')
172 self.call('nbconvert --log-level 0')
173 assert os.path.isfile('notebook1.py')
173 assert os.path.isfile('notebook1.py')
174 assert not os.path.isfile('notebook2.py')
174 assert not os.path.isfile('notebook2.py')
175
175
176
176
177 def test_override_config(self):
177 def test_override_config(self):
178 """
178 """
179 Can the default config be overriden?
179 Can the default config be overriden?
180 """
180 """
181 with self.create_temp_cwd(['notebook*.ipynb',
181 with self.create_temp_cwd(['notebook*.ipynb',
182 'ipython_nbconvert_config.py',
182 'ipython_nbconvert_config.py',
183 'override.py']):
183 'override.py']):
184 self.call('nbconvert --log-level 0 --config="override.py"')
184 self.call('nbconvert --log-level 0 --config="override.py"')
185 assert not os.path.isfile('notebook1.py')
185 assert not os.path.isfile('notebook1.py')
186 assert os.path.isfile('notebook2.py')
186 assert os.path.isfile('notebook2.py')
187
187
188 def test_accents_in_filename(self):
188 def test_accents_in_filename(self):
189 """
189 """
190 Can notebook names include accents?
190 Can notebook names include accents?
191 """
191 """
192 with self.create_temp_cwd(['nb*.ipynb']):
192 with self.create_temp_cwd(['nb*.ipynb']):
193 self.call('nbconvert --log-level 0 --to python nb1_*')
193 self.call('nbconvert --log-level 0 --to python nb1_*')
194 assert os.path.isfile(u'nb1_análisis.py')
194 assert os.path.isfile(u'nb1_análisis.py')
195
195
196 @dec.onlyif_cmds_exist('pdflatex')
196 @dec.onlyif_cmds_exist('pdflatex')
197 @dec.onlyif_cmds_exist('pandoc')
197 @dec.onlyif_cmds_exist('pandoc')
198 def test_filename_spaces(self):
198 def test_filename_accent(self):
199 """
199 """
200 Generate PDFs if notebooks have an accent in their name?
200 Generate PDFs if notebooks have an accent in their name?
201 """
201 """
202 with self.create_temp_cwd(['nb*.ipynb']):
202 with self.create_temp_cwd(['nb*.ipynb']):
203 o,e = self.call('nbconvert --log-level 0 --to latex '
203 o,e = self.call('nbconvert --log-level 0 --to latex '
204 '"nb1_*" --post PDF '
204 '"nb1_*" --post PDF '
205 '--PDFPostProcessor.verbose=True')
205 '--PDFPostProcessor.verbose=True')
206 assert os.path.isfile(u'nb1_análisis.tex')
206 assert os.path.isfile(u'nb1_análisis.tex')
207 assert os.path.isfile(u'nb1_análisis.pdf')
207 assert os.path.isfile(u'nb1_análisis.pdf')
General Comments 0
You need to be logged in to leave comments. Login now