rst and pypandoc

alb al.basili at gmail.com
Mon Mar 2 17:37:06 EST 2015


Hi MRAB,

MRAB <python at mrabarnett.plus.com> wrote:
[]
> Have you tried escaping the escape character by doubling the backslash?
> 
> inp = '\\\\ref{fig:abc}'

In [54]: inp = '\\\\ref{fig:abc}'

In [55]: print pypandoc.convert(inp, 'latex', format='rst')
\textbackslash{}ref\{fig:abc\}

the backslash is considered as literal text for latex and is escaped 
with the appropriate command.

> or:
> 
> inp = r'\\ref{fig:abc}'
> 

In [56]: inp = r'\\ref{fig:abc}'

In [57]: print pypandoc.convert(inp, 'latex', format='rst')
\textbackslash{}ref\{fig:abc\}

same as above. The result I aim to would be:

In [BINGO]: print pypandoc.convert(inp, 'latex', format='rst')
\ref{fig:abc}

Al




More information about the Python-list mailing list