def test_escape(): assert latex_escape(r'\naughty') == r'\textbackslash{}naughty' assert ( latex_escape(r'this\\is\\harmless') == r'this\textbackslash{}\textbackslash{}is\textbackslash{}\textbackslash{}harmless' ) assert latex_escape( r'\\\extranaughty' ) == r'\textbackslash{}\textbackslash{}\textbackslash{}extranaughty'
def _escape_latex_math(string): return mdx_latex.latex_escape(string, ignore_math=True)
def test_escape_math(): assert latex_escape(r'$\naughty$') == r'\protect $\\naughty$' assert latex_escape(r'$\\naughty$') == r'\protect $\\naughty$' assert latex_escape(r'$harm\\less$') == r'\protect $harm\\less$' assert latex_escape(r'$\\\extranaughty$') == r'\protect $\\\\extranaughty$'
def _latex_escape(s, ignore_braces=False): if not isinstance(s, basestring) or isinstance(s, RawLatex): return s if isinstance(s, str): s = s.decode('utf-8') return RawLatex(mdx_latex.latex_escape(s, ignore_braces=ignore_braces))
def _latex_escape(s, ignore_braces=False): if not isinstance(s, str) or isinstance(s, RawLatex): return s return RawLatex(mdx_latex.latex_escape(s, ignore_braces=ignore_braces))
def _latex_escape(s, ignore_braces=False): if not isinstance(s, basestring) or isinstance(s, RawLatex): return s return RawLatex(mdx_latex.latex_escape(s, ignore_braces=ignore_braces))