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: 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 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: In-Reply-To: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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 When I try to escape with '\' i = '\\ref{fig:abc}' I get the following exception: -- DaveA