Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #86724
| Date | 2015-03-02 07:03 -0500 |
|---|---|
| From | Dave Angel <davea@davea.name> |
| Subject | Re: rst and pypandoc |
| References | <cliji5FvctU1@mid.individual.net> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.33.1425297846.13471.python-list@python.org> (permalink) |
On 03/02/2015 02:59 AM, alb wrote:
> Hi everyone,
>
> I'm writing a document in restructured text and I'd like to convert it
> to latex for printing. To accomplish this I've used semi-successfully
> pandoc and the wrapper pypandoc.
I don't see other responses yet, so I'll respond even though i don't
know pyandoc.
>
> My biggest issue is with figures and references to them. We've our macro
> to allocate figures so I'm forced to bypass the rst directive /..
> figure/, moreover I haven't happened to find how you can reference to a
> figure in the rst docs.
>
> For all the above reasons I'm writing snippets of pure latex in my rst
> doc, but I'm having issues with the escape characters:
>
> i = '\ref{fig:abc}'
> print pypandoc.convert(i, 'latex', format='rst')
> ef\{fig:abc\}
>
> because of the \r that is interpreted by python as special character.
I don't know whether your problem is understanding what Python does with
literals, or what pyandoc wants. I can only help with the former.
You could try printing the i to see what it looks like, if you don't
understand Python literal escaping. Perhaps something like:
print "++" + i + "++"
Those pluses tend to help figure out what happens when you have control
codes mixed in the line. For example as it stands, the 0x0d character
will have the effect of overwriting those first two "++"
A second method is to look at the string in hex:
print i.encode("hex")
>
> If I try to escape with '\' I don't seem to find a way out...
You should be a lot more explicit with all three parts of that
statement. Try:
I'm trying to get a string of
<here you show the string you expected from that convert statement>
When I try to escape with '\'
i = '\\ref{fig:abc}'
I get the following exception:
<here you include the traceback>
--
DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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