"""Citation handling for LaTeX output.""" #----------------------------------------------------------------------------- # 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. #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Code #----------------------------------------------------------------------------- __all__ = ['parse_citation'] def parse_citation(s): """Parse citations in Markdown cells. This looks for HTML tags having a data attribute names `data-cite` and replaces it by the call to LaTeX cite command. The tranformation looks like this: `(Granger, 2013)` Becomes `\\cite{granger}` Any HTML tag can be used, which allows the citations to be formatted in HTML in any manner. """ try: from lxml import html except ImportError: return s tree = html.fragment_fromstring(s, create_parent='div') _process_node_cite(tree) s = html.tostring(tree) s = s.lstrip('