rst and pypandoc
alb
al.basili at gmail.com
Tue Mar 3 15:35:43 EST 2015
Hi Steven,
Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
[]
>> In [43]: print pypandoc.convert(s, 'latex', format='rst')
>> this is \textbackslash{}some restructured text.
>>
>> since a literal backslash gets converted to a literal latex backslash.
>
> Why is this a problem? Isn't the ultimate aim to pass it through latex,
> which will then covert the \textbackslash{} back into a backslash? If not,
> I have misunderstood something.
\textbackslash{} is a latex command to typeset a backslash into the
text. This is not what I need. I need to have a string of the form
"\some" (actually we are talking about \ref or \hyperref commands).
> If not, you could do something like this:
>
> s = 'this is %(b)ssome restructured text.'
> t = pypandoc.convert(s, 'latex', format='rst')
> assert t == 'this is %(b)ssome restructured text.'
> print t % {'b': '\\'}
This is somehow what I'm doing now, but is very dirty and difficult to
expand to other corner cases.
Al
More information about the Python-list
mailing list