From 5ac3d9ac4bd6cac763ae2a5313eade6c0b7e44c3 2013-08-27 04:53:25 From: Brian E. Granger Date: 2013-08-27 04:53:25 Subject: [PATCH] Addressing review comments. * Rename parse_citation to citation2latex. * Add

block to test markdown. --- diff --git a/IPython/nbconvert/exporters/exporter.py b/IPython/nbconvert/exporters/exporter.py index f15cb9c..e84b6fe 100755 --- a/IPython/nbconvert/exporters/exporter.py +++ b/IPython/nbconvert/exporters/exporter.py @@ -68,7 +68,7 @@ default_filters = { 'strip_math_space': filters.strip_math_space, 'wrap_text': filters.wrap_text, 'escape_latex': filters.escape_latex, - 'parse_citation': filters.parse_citation + 'citation2latex': filters.citation2latex } #----------------------------------------------------------------------------- diff --git a/IPython/nbconvert/filters/citation.py b/IPython/nbconvert/filters/citation.py index 4fbb868..9bc8345 100644 --- a/IPython/nbconvert/filters/citation.py +++ b/IPython/nbconvert/filters/citation.py @@ -13,10 +13,10 @@ #----------------------------------------------------------------------------- -__all__ = ['parse_citation'] +__all__ = ['citation2latex'] -def parse_citation(s): +def citation2latex(s): """Parse citations in Markdown cells. This looks for HTML tags having a data attribute names `data-cite` diff --git a/IPython/nbconvert/filters/tests/test_citation.py b/IPython/nbconvert/filters/tests/test_citation.py index 7bb033b..7f068c2 100644 --- a/IPython/nbconvert/filters/tests/test_citation.py +++ b/IPython/nbconvert/filters/tests/test_citation.py @@ -10,7 +10,7 @@ # Imports #----------------------------------------------------------------------------- -from ..citation import parse_citation +from ..citation import citation2latex #----------------------------------------------------------------------------- # Tests @@ -25,6 +25,8 @@ velit, lobortis sed interdum at, vestibulum vitae libero Thomas. Quisque iaculis ligula ut ipsum mattis viverra. +

Here is a plain paragraph that should be unaffected.

+ * One Jonathan. * Two Matthias. * Three Paul. @@ -39,16 +41,18 @@ velit, lobortis sed interdum at, vestibulum vitae libero \cite{fperez}. Lorem ipsum dolor sit amet, consectetur adipiscing elit \cite{takluyver}. Quisque iaculis ligula ut ipsum mattis viverra. +

Here is a plain paragraph that should be unaffected.

+ * One \cite{jdfreder}. * Two \cite{carreau}. * Three \cite{ivanov}. """ -def test_parse_citation(): +def test_citation2latex(): """Are citations parsed properly?""" try: import lxml except ImportError: - assert test_md == parse_citation(test_md) + assert test_md == citation2latex(test_md) else: - assert test_md_parsed == parse_citation(test_md) + assert test_md_parsed == citation2latex(test_md) diff --git a/IPython/nbconvert/templates/latex/latex_basic.tplx b/IPython/nbconvert/templates/latex/latex_basic.tplx index d8d6e68..8b1c9da 100644 --- a/IPython/nbconvert/templates/latex/latex_basic.tplx +++ b/IPython/nbconvert/templates/latex/latex_basic.tplx @@ -103,11 +103,11 @@ it introduces a new line ((* endblock stream *)) ((* block markdowncell scoped *)) -((( cell.source | parse_citation | markdown2latex ))) +((( cell.source | citation2latex | markdown2latex ))) ((* endblock markdowncell *)) ((* block headingcell scoped -*)) -((( ('#' * cell.level + cell.source) | replace('\n', ' ') | parse_citation | markdown2latex ))) +((( ('#' * cell.level + cell.source) | replace('\n', ' ') | citation2latex | markdown2latex ))) ((* endblock headingcell *)) ((* block rawcell scoped *)) diff --git a/IPython/nbconvert/templates/latex/sphinx.tplx b/IPython/nbconvert/templates/latex/sphinx.tplx index 80ee3fb..06b32ae 100644 --- a/IPython/nbconvert/templates/latex/sphinx.tplx +++ b/IPython/nbconvert/templates/latex/sphinx.tplx @@ -232,7 +232,7 @@ Note: For best display, use latex syntax highlighting. =)) in IPYNB file titles) do not make their way into latex. Sometimes this causes latex to barf. =)) ((*- endif -*)) - {((( cell.source | parse_citation | markdown2latex )))} + {((( cell.source | citation2latex | markdown2latex )))} ((*- endblock headingcell *)) %============================================================================== @@ -242,7 +242,7 @@ Note: For best display, use latex syntax highlighting. =)) % called since we know we want latex output. %============================================================================== ((*- block markdowncell scoped-*)) -((( cell.source | parse_citation | markdown2latex ))) +((( cell.source | citation2latex | markdown2latex ))) ((*- endblock markdowncell -*)) %==============================================================================