Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #86729

Re: rst and pypandoc

From al.basili@gmail.com (alb)
Newsgroups comp.lang.python
Subject Re: rst and pypandoc
Date 2015-03-02 12:36 +0000
Message-ID <clj3qjF54bcU1@mid.individual.net> (permalink)
References <cliji5FvctU1@mid.individual.net> <mailman.33.1425297846.13471.python-list@python.org>

Show all headers | View raw


Hi Dave,

Dave Angel <davea@davea.name> wrote:
[]
> You should be a lot more explicit with all three parts of that 
> statement.  Try:
> 
> 
> I'm trying to get a string of

\ref{fig:A.B}

but unfortunately I need to go through a conversion between rst and 
latex. This is because a simple text like this:

<rst-text>
this is a simple list of items:

 - item A.
 - item B.

</rst-text>

gets translated into latex by pypandoc as this:

<latex-text>
\begin{itemize}
  \item item A.
  \item item B.
\end{itemize}
<latex-text>

And it's much simpler to write my document with rst markup rather than latex.

So my question is what should my restructured text look like in order to 
get it through pypandoc and get the following:

\ref{fig:abc}


Apparently rst only allows the following type of references:

- external hyperlink targets
- internal hyperlink targets
- indirect hyperlink targets
- implicit hyperlink targets

and I want to get a later that has a reference to a figure, but none of 
those seem to be able to do so. Therefore I thought about passing an 
inline text in my rst in order to get it through the conversion as is, 
but apparently I'm stuck with the various escaping mechanisms.

My python script reads the text and passes it on to pypandoc:

i = "%\n" % text
o = pypandoc.convert(i, 'latex', format='rst')

So if text is:

<text>
this is some text with a reference to Figure \ref{fig:abc}
</text>

I would like o to be like:

this is some text with a reference to Figaure \ref{fig:abc}

but I get:

ef\{fig:abc\}

Al

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

rst and pypandoc al.basili@gmail.com (alb) - 2015-03-02 07:59 +0000
  Re: rst and pypandoc Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2015-03-02 12:03 +0100
  Re: rst and pypandoc Dave Angel <davea@davea.name> - 2015-03-02 07:03 -0500
    Re: rst and pypandoc al.basili@gmail.com (alb) - 2015-03-02 12:36 +0000
  Re: rst and pypandoc Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-02 23:33 +1100
    Re: rst and pypandoc al.basili@gmail.com (alb) - 2015-03-02 13:51 +0000
      Re: rst and pypandoc Dave Angel <davea@davea.name> - 2015-03-02 09:08 -0500
        Re: rst and pypandoc Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-03 01:43 +1100
          Re: rst and pypandoc Dave Angel <davea@davea.name> - 2015-03-02 13:55 -0500
          Re: rst and pypandoc Ben Finney <ben+python@benfinney.id.au> - 2015-03-03 06:09 +1100
          Re: rst and pypandoc Dave Angel <davea@davea.name> - 2015-03-02 14:16 -0500
        Re: rst and pypandoc al.basili@gmail.com (alb) - 2015-03-02 22:30 +0000
          Re: rst and pypandoc Chris Angelico <rosuav@gmail.com> - 2015-03-03 09:51 +1100
          Re: rst and pypandoc Ben Finney <ben+python@benfinney.id.au> - 2015-03-03 10:18 +1100
          Re: rst and pypandoc Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-03 10:32 +1100
            Re: rst and pypandoc al.basili@gmail.com (alb) - 2015-03-03 20:35 +0000
        Re: rst and pypandoc al.basili@gmail.com (alb) - 2015-03-02 22:40 +0000
          Re: rst and pypandoc Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-03-02 23:08 +0000
            Re: rst and pypandoc al.basili@gmail.com (alb) - 2015-03-03 20:37 +0000
          Re: rst and pypandoc Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-03 10:22 +1100
            Re: rst and pypandoc al.basili@gmail.com (alb) - 2015-03-03 20:46 +0000
          Re: rst and pypandoc Dave Angel <davea@davea.name> - 2015-03-02 18:23 -0500
      Re: rst and pypandoc MRAB <python@mrabarnett.plus.com> - 2015-03-02 14:37 +0000
        Re: rst and pypandoc al.basili@gmail.com (alb) - 2015-03-02 22:37 +0000
          Re: rst and pypandoc Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-03-03 19:40 +1300
            Re: rst and pypandoc al.basili@gmail.com (alb) - 2015-03-03 20:50 +0000
              Re: rst and pypandoc Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-03-04 11:27 +1300
      Re: rst and pypandoc MRAB <python@mrabarnett.plus.com> - 2015-03-02 14:40 +0000
      Re: rst and pypandoc Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-03 02:09 +1100

csiph-web