##// END OF EJS Templates
Revert PR #5388...
Revert PR #5388 We realised that #5388 introduces a different problem of about the same magnitude as the one it fixes (both are quite minor). A proper fix would be too invasive this close to release, and after discussion, we decided it was better to leave the same problem that has been in previous releases.

File last commit:

r15055:7a32c8cc
r15886:7bba2551
Show More
test_citation.py
150 lines | 4.1 KiB | text/x-python | PythonLexer
Brian E. Granger
Adding citation support.
r12265 #-----------------------------------------------------------------------------
# Copyright (c) 2013, the IPython Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
Brian E. Granger
Addressing review comments....
r12299 from ..citation import citation2latex
Thomas Kluyver
Improve test for nbconvert citation filter....
r13989 from nose.tools import assert_equal
Brian E. Granger
Adding citation support.
r12265
#-----------------------------------------------------------------------------
# Tests
#-----------------------------------------------------------------------------
Jonathan Frederic
Added 18 more citation tests...
r15054 test_md = {"""
Brian E. Granger
Adding citation support.
r12265 # My Heading
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ac magna non augue
porttitor scelerisque ac id diam <cite data-cite="granger">Granger</cite>. Mauris elit
velit, lobortis sed interdum at, vestibulum vitae libero <strong data-cite="fperez">Perez</strong>.
Lorem ipsum dolor sit amet, consectetur adipiscing elit
<em data-cite="takluyver">Thomas</em>. Quisque iaculis ligula ut ipsum mattis viverra.
jakobgager
Update tests
r15052 <p>Here is a plain paragraph that should be unaffected. It contains simple
relations like 1<2 & 4>5.</p>
Brian E. Granger
Addressing review comments....
r12299
Brian E. Granger
Adding citation support.
r12265 * One <cite data-cite="jdfreder">Jonathan</cite>.
* Two <cite data-cite="carreau">Matthias</cite>.
* Three <cite data-cite="ivanov">Paul</cite>.
Jonathan Frederic
Added 18 more citation tests...
r15054 """: """
Brian E. Granger
Adding citation support.
r12265 # My Heading
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ac magna non augue
porttitor scelerisque ac id diam \cite{granger}. Mauris elit
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.
jakobgager
Update tests
r15052 <p>Here is a plain paragraph that should be unaffected. It contains simple
relations like 1<2 & 4>5.</p>
Brian E. Granger
Addressing review comments....
r12299
Brian E. Granger
Adding citation support.
r12265 * One \cite{jdfreder}.
* Two \cite{carreau}.
* Three \cite{ivanov}.
Jonathan Frederic
Added 18 more citation tests...
r15054 """,
# No citations
r"""The quick brown fox jumps over the lazy dog.""":
r"""The quick brown fox jumps over the lazy dog.""",
# Simple inline
r"""Foo <cite data-cite=asdf>Text</cite> bar""":
r"""Foo \cite{asdf} bar""",
# Multiline
r"""<cite data-cite=ewqr>Text
</cite>Foo""":
r"""\cite{ewqr}Foo""",
# Nested tags
r"""<div><div data-cite=Foo><div>Text</div></div></div> Bar""":
r"""<div>\cite{Foo}</div> Bar""",
# Including Maths
r"""Foo $3*2*1$ <div data-cite=Foo>Text</div> Bar""":
r"""Foo $3*2*1$ \cite{Foo} Bar""",
# Missing end tag
r"""<cite data-cite=asdf>Test Foo""":
r"""\cite{asdf}""",
r"""<cite data-cite=asdf><cite>Test Foo""":
r"""\cite{asdf}""",
r"""<cite data-cite=asdf><cite>Test</cite> Foo""":
r"""\cite{asdf}""",
# Multiple arguments
r"""<cite width=qwer data-cite=asdf>Test</cite> Foo""":
r"""\cite{asdf} Foo""",
# Wrong capitalization
r"""<CITE data-cite=asdf>Test</cite> Foo""":
r"""\cite{asdf} Foo""",
r"""<cite DATA-CITE=asdf>Test</cite> Foo""":
r"""\cite{asdf} Foo""",
# Wrong end tag
r"""<asd data-cite=wer> ksjfs </asdf> sdf ds """:
r"""\cite{wer}""",
r"""<asd data-cite=wer>""":
r"""\cite{wer}""",
# Invalid tag names
r"""<frog> <foo data-cite=wer></foo>""":
r"""<frog> \cite{wer}""",
# Non-nested tags
r"""<strong> <h1> <cite data-cite=asdf></cite>Test</strong> Foo </h1>""":
r"""<strong> <h1> \cite{asdf}Test</strong> Foo </h1>""",
# LXML errors
r"""Foo
\begin{eqnarray}
1 & <cite data-cite=bar>bar1</cite> \\
3 & 4 \\
\end{eqnarray}""":
r"""Foo
\begin{eqnarray}
1 & \cite{bar} \\
3 & 4 \\
\end{eqnarray}""",
r"""
1<2 is true, but 3>4 is false.
$1<2$ is true, but $3>4$ is false.
1<2 it is even worse if it is alone in a line.""":
r"""
1<2 is true, but 3>4 is false.
$1<2$ is true, but $3>4$ is false.
1<2 it is even worse if it is alone in a line.""",
r"""
1 < 2 is true, but 3 > 4 is false
$1 < 2$ is true, but $3 > 4$ is false
1 < 2 it is even worse if it is alone in a line.
""":
r"""
1 < 2 is true, but 3 > 4 is false
$1 < 2$ is true, but $3 > 4$ is false
1 < 2 it is even worse if it is alone in a line.
"""}
Brian E. Granger
Adding citation support.
r12265
Brian E. Granger
Addressing review comments....
r12299 def test_citation2latex():
Brian E. Granger
Adding citation support.
r12265 """Are citations parsed properly?"""
Jonathan Frederic
Added 18 more citation tests...
r15054 for input, output in test_md.items():
yield (assert_equal, citation2latex(input), output)