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


Groups > comp.lang.python > #86724

Re: rst and pypandoc

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <davea@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'explicit': 0.07; 'string': 0.09; 'escape': 0.09; 'interpreted': 0.09; 'literal': 0.09; 'mixed': 0.09; 'try:': 0.09; 'wrapper': 0.09; 'python': 0.11; 'character.': 0.16; 'characters:': 0.16; 'directive': 0.16; 'docs.': 0.16; 'exception:': 0.16; 'hex:': 0.16; 'literals,': 0.16; 'overwriting': 0.16; 'printing.': 0.16; 'restructured': 0.16; 'statement.': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'everyone,': 0.19; 'figures': 0.19; 'example': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'tend': 0.24; "haven't": 0.24; 'looks': 0.24; "i've": 0.25; 'references': 0.26; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'character': 0.29; "i'm": 0.30; "skip:' 10": 0.31; 'figure': 0.32; 'text': 0.33; "i'd": 0.34; 'could': 0.34; 'problem': 0.35; 'something': 0.35; 'convert': 0.35; 'but': 0.35; 'like,': 0.36; 'method': 0.36; "i'll": 0.36; 'should': 0.36; 'two': 0.37; 'to:addr:python-list': 0.38; 'issue': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'even': 0.60; 'skip:u 10': 0.60; 'first': 0.61; 'our': 0.64; 'more': 0.64; 'charset:windows-1252': 0.65; 'biggest': 0.67; 'received:74.208': 0.68; 'special': 0.74; 'forced': 0.84; 'responses': 0.93
Date Mon, 02 Mar 2015 07:03:52 -0500
From Dave Angel <davea@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0
MIME-Version 1.0
To python-list@python.org
Subject Re: rst and pypandoc
References <cliji5FvctU1@mid.individual.net>
In-Reply-To <cliji5FvctU1@mid.individual.net>
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:a9LD3C2pifV2p77rxY5cEnBFq4ff2cycD8YWH8MDkVP 8wQC8dJDRuR73FTDlZTlgegDXCwzB+7tkW90aDpMV8MlKSPPLH lIc9U5QXNXKbMmK7oGU6bdVMe5ybYd3fDyMKAN60HUXgHZx6BI r4IU8UqfuJnghgwmytpa5gIWQwpwGKXOZq0dJC8ONJBUnA7nIN zOFbWeYHfVeImOLJwN+Bb6WbgmqxXEr1F1nREIjE/wP+RkmyUJ 4wsVbS61cKYk8Ou642a+m0XS9n+9jmQNF61+xAc1kpybJPt+lp 1wemABEeRsWZDxC9IRM9bTx9v2KP3aXLKQgqesTqKedztZB1vn 5KoRxj2dG7P14eJtEc+c=
X-UI-Out-Filterresults notjunk:1;
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.33.1425297846.13471.python-list@python.org> (permalink)
Lines 64
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1425297846 news.xs4all.nl 2847 [2001:888:2000:d::a6]:42330
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:86724

Show key headers only | View raw


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 | 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