##// END OF EJS Templates
Addressing review comments....
Brian E. Granger -
Show More
@@ -68,7 +68,7 b' default_filters = {'
68 'strip_math_space': filters.strip_math_space,
68 'strip_math_space': filters.strip_math_space,
69 'wrap_text': filters.wrap_text,
69 'wrap_text': filters.wrap_text,
70 'escape_latex': filters.escape_latex,
70 'escape_latex': filters.escape_latex,
71 'parse_citation': filters.parse_citation
71 'citation2latex': filters.citation2latex
72 }
72 }
73
73
74 #-----------------------------------------------------------------------------
74 #-----------------------------------------------------------------------------
@@ -13,10 +13,10 b''
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14
14
15
15
16 __all__ = ['parse_citation']
16 __all__ = ['citation2latex']
17
17
18
18
19 def parse_citation(s):
19 def citation2latex(s):
20 """Parse citations in Markdown cells.
20 """Parse citations in Markdown cells.
21
21
22 This looks for HTML tags having a data attribute names `data-cite`
22 This looks for HTML tags having a data attribute names `data-cite`
@@ -10,7 +10,7 b''
10 # Imports
10 # Imports
11 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12
12
13 from ..citation import parse_citation
13 from ..citation import citation2latex
14
14
15 #-----------------------------------------------------------------------------
15 #-----------------------------------------------------------------------------
16 # Tests
16 # Tests
@@ -25,6 +25,8 b' velit, lobortis sed interdum at, vestibulum vitae libero <strong data-cite="fper'
25 Lorem ipsum dolor sit amet, consectetur adipiscing elit
25 Lorem ipsum dolor sit amet, consectetur adipiscing elit
26 <em data-cite="takluyver">Thomas</em>. Quisque iaculis ligula ut ipsum mattis viverra.
26 <em data-cite="takluyver">Thomas</em>. Quisque iaculis ligula ut ipsum mattis viverra.
27
27
28 <p>Here is a plain paragraph that should be unaffected.</p>
29
28 * One <cite data-cite="jdfreder">Jonathan</cite>.
30 * One <cite data-cite="jdfreder">Jonathan</cite>.
29 * Two <cite data-cite="carreau">Matthias</cite>.
31 * Two <cite data-cite="carreau">Matthias</cite>.
30 * Three <cite data-cite="ivanov">Paul</cite>.
32 * Three <cite data-cite="ivanov">Paul</cite>.
@@ -39,16 +41,18 b' velit, lobortis sed interdum at, vestibulum vitae libero \\cite{fperez}.'
39 Lorem ipsum dolor sit amet, consectetur adipiscing elit
41 Lorem ipsum dolor sit amet, consectetur adipiscing elit
40 \cite{takluyver}. Quisque iaculis ligula ut ipsum mattis viverra.
42 \cite{takluyver}. Quisque iaculis ligula ut ipsum mattis viverra.
41
43
44 <p>Here is a plain paragraph that should be unaffected.</p>
45
42 * One \cite{jdfreder}.
46 * One \cite{jdfreder}.
43 * Two \cite{carreau}.
47 * Two \cite{carreau}.
44 * Three \cite{ivanov}.
48 * Three \cite{ivanov}.
45 """
49 """
46
50
47 def test_parse_citation():
51 def test_citation2latex():
48 """Are citations parsed properly?"""
52 """Are citations parsed properly?"""
49 try:
53 try:
50 import lxml
54 import lxml
51 except ImportError:
55 except ImportError:
52 assert test_md == parse_citation(test_md)
56 assert test_md == citation2latex(test_md)
53 else:
57 else:
54 assert test_md_parsed == parse_citation(test_md)
58 assert test_md_parsed == citation2latex(test_md)
@@ -103,11 +103,11 b' it introduces a new line'
103 ((* endblock stream *))
103 ((* endblock stream *))
104
104
105 ((* block markdowncell scoped *))
105 ((* block markdowncell scoped *))
106 ((( cell.source | parse_citation | markdown2latex )))
106 ((( cell.source | citation2latex | markdown2latex )))
107 ((* endblock markdowncell *))
107 ((* endblock markdowncell *))
108
108
109 ((* block headingcell scoped -*))
109 ((* block headingcell scoped -*))
110 ((( ('#' * cell.level + cell.source) | replace('\n', ' ') | parse_citation | markdown2latex )))
110 ((( ('#' * cell.level + cell.source) | replace('\n', ' ') | citation2latex | markdown2latex )))
111 ((* endblock headingcell *))
111 ((* endblock headingcell *))
112
112
113 ((* block rawcell scoped *))
113 ((* block rawcell scoped *))
@@ -232,7 +232,7 b' Note: For best display, use latex syntax highlighting. =))'
232 in IPYNB file titles) do not make their way into latex. Sometimes this
232 in IPYNB file titles) do not make their way into latex. Sometimes this
233 causes latex to barf. =))
233 causes latex to barf. =))
234 ((*- endif -*))
234 ((*- endif -*))
235 {((( cell.source | parse_citation | markdown2latex )))}
235 {((( cell.source | citation2latex | markdown2latex )))}
236 ((*- endblock headingcell *))
236 ((*- endblock headingcell *))
237
237
238 %==============================================================================
238 %==============================================================================
@@ -242,7 +242,7 b' Note: For best display, use latex syntax highlighting. =))'
242 % called since we know we want latex output.
242 % called since we know we want latex output.
243 %==============================================================================
243 %==============================================================================
244 ((*- block markdowncell scoped-*))
244 ((*- block markdowncell scoped-*))
245 ((( cell.source | parse_citation | markdown2latex )))
245 ((( cell.source | citation2latex | markdown2latex )))
246 ((*- endblock markdowncell -*))
246 ((*- endblock markdowncell -*))
247
247
248 %==============================================================================
248 %==============================================================================
General Comments 0
You need to be logged in to leave comments. Login now