Re: rst and pypandoc

2015-03-03 Thread Gregory Ewing
alb wrote: RuntimeError: Invalid input format! Expected one of these: native, json, markdown, markdown+lhs, rst, rst+lhs, docbook, textile, html, latex, latex+lhs It looks like it's expecting the base format to be spelled "markdown", not abbreviated to "md". (The python wrapper expands "md" to

Re: rst and pypandoc

2015-03-03 Thread alb
Hi Gregory, Gregory Ewing wrote: [] > From a cursory reading of the pypandoc docs, it looks > like enabling the raw_tex extension in pypandoc will > give you what you want. > > Search for raw_tex on this page: > > http://johnmacfarlane.net/pandoc/README.html As far as I understood the docs, it

Re: rst and pypandoc

2015-03-03 Thread alb
Hi Steven, Steven D'Aprano wrote: [] >> The two results are clearly *not* the same, even though the two inp >> /claim/ to be the same... > > The two inp are not the same. Correct. My statement was wrong. [] > I'm sure that you know how to do such simple things to investigate whether > two inpu

Re: rst and pypandoc

2015-03-03 Thread alb
Hi Mark, Mark Lawrence wrote: [] > The two inps are *not* the same. My bad. I did not notice the difference, thanks for pointing that out. Al -- https://mail.python.org/mailman/listinfo/python-list

Re: rst and pypandoc

2015-03-03 Thread alb
Hi Steven, Steven D'Aprano 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

Re: rst and pypandoc

2015-03-03 Thread Dave Angel
On 03/02/2015 02:09 PM, Ben Finney wrote: Dave Angel writes: And D'oh right back at ya. Ironic isn't it that I make a second mistake in the same message I correct yours? https://en.wikipedia.org/wiki/Muphry%27s_law> I guess that word is too small to qualify as a malapropism, a word which

Re: rst and pypandoc

2015-03-02 Thread Gregory Ewing
alb wrote: The result I aim to would be: In [BINGO]: print pypandoc.convert(inp, 'latex', format='rst') \ref{fig:abc} From a cursory reading of the pypandoc docs, it looks like enabling the raw_tex extension in pypandoc will give you what you want. Search for raw_tex on this page: http://joh

Re: rst and pypandoc

2015-03-02 Thread Steven D'Aprano
alb wrote: > In [39]: print pypandoc.convert(s, 'latex', format='rst') > this is some restructured text. > > what happened to my backslash??? You'll need to read your pypandoc documentation to see what it says about backslashes. > If I try to escape my backslash I get something worse: > > In

Re: rst and pypandoc

2015-03-02 Thread Dave Angel
On 03/02/2015 05:40 PM, alb wrote: Hi Dave, Dave Angel wrote: [] or use a raw string: i = r'\\ref{fig:abc}' Actually that'd be: i = r'\ref{fig:abc}' Could you explain why I then see the following difference: In [56]: inp = r'\\ref{fig:abc}' print inp and you should get \\re

Re: rst and pypandoc

2015-03-02 Thread Steven D'Aprano
alb wrote: > Could you explain why I then see the following difference: > > In [56]: inp = r'\\ref{fig:abc}' > > In [57]: print pypandoc.convert(inp, 'latex', format='rst') > \textbackslash{}ref\{fig:abc\} > > > In [58]: inp = r'\ref{fig:abc}' > > In [59]: print pypandoc.convert(inp, 'latex',

Re: rst and pypandoc

2015-03-02 Thread Ben Finney
Chris Angelico writes: > And of course, that means you have to escape the backslash if you want > to have one in the text. But all of this is just for putting *string > literals* into your source code. If it's not Python source code, these > rules don't apply. You can read a line of text from the

Re: rst and pypandoc

2015-03-02 Thread Mark Lawrence
On 02/03/2015 22:40, alb wrote: Hi Dave, Dave Angel wrote: [] or use a raw string: i = r'\\ref{fig:abc}' Actually that'd be: i = r'\ref{fig:abc}' Could you explain why I then see the following difference: In [56]: inp = r'\\ref{fig:abc}' In [57]: print pypandoc.convert(inp, 'latex',

Re: rst and pypandoc

2015-03-02 Thread Chris Angelico
On Tue, Mar 3, 2015 at 9:30 AM, alb wrote: > Hi Dave, > > Dave Angel wrote: > [] >>> Rst escapes with "\", but unfortunately python also uses "\" for escaping! >> >> Only when the string is in a literal. If you've read it from a file, or >> built it by combining other strings, or... then the ba

Re: rst and pypandoc

2015-03-02 Thread alb
Hi Dave, Dave Angel wrote: [] >>> or use a raw string: >>> >>> i = r'\\ref{fig:abc}' > > Actually that'd be: >i = r'\ref{fig:abc}' Could you explain why I then see the following difference: In [56]: inp = r'\\ref{fig:abc}' In [57]: print pypandoc.convert(inp, 'latex', format='rst') \textb

Re: rst and pypandoc

2015-03-02 Thread alb
Hi MRAB, MRAB wrote: [] > Have you tried escaping the escape character by doubling the backslash? > > inp = 'ref{fig:abc}' In [54]: inp = 'ref{fig:abc}' In [55]: print pypandoc.convert(inp, 'latex', format='rst') \textbackslash{}ref\{fig:abc\} the backslash is considered as literal te

Re: rst and pypandoc

2015-03-02 Thread alb
Hi Dave, Dave Angel wrote: [] >> Rst escapes with "\", but unfortunately python also uses "\" for escaping! > > Only when the string is in a literal. If you've read it from a file, or > built it by combining other strings, or... then the backslash is just > another character to Python. Holy

Re: rst and pypandoc

2015-03-02 Thread Ben Finney
Dave Angel writes: > And D'oh right back at ya. Ironic isn't it that I make a second > mistake in the same message I correct yours? https://en.wikipedia.org/wiki/Muphry%27s_law> -- \ “Truth would quickly cease to become stranger than fiction, | `\ once we got as

Re: rst and pypandoc

2015-03-02 Thread Dave Angel
On 03/02/2015 09:43 AM, Steven D'Aprano wrote: Dave Angel wrote: On 03/02/2015 08:51 AM, alb wrote: Hi Steven, Steven D'Aprano wrote: or use a raw string: i = r'\\ref{fig:abc}' Actually that'd be: i = r'\ref{fig:abc}' D'oh! I mean, you spotted my deliberate mistake to check i

Re: rst and pypandoc

2015-03-02 Thread Steven D'Aprano
alb wrote: > Hi Steven, > > Steven D'Aprano wrote: > [] >> Since \r is an escape character, that will give you carriage return >> followed by "ef{fig:abc". >> >> The solution to that is to either escape the backslash: >> >> i = '\\ref{fig:abc}' >> >> >> or use a raw string: >> >> i = r'\\re

Re: rst and pypandoc

2015-03-02 Thread Steven D'Aprano
Dave Angel wrote: > On 03/02/2015 08:51 AM, alb wrote: >> Hi Steven, >> >> Steven D'Aprano wrote: >> [] >>> Since \r is an escape character, that will give you carriage return >>> followed by "ef{fig:abc". >>> >>> The solution to that is to either escape the backslash: >>> >>> i = '\\ref{fig:abc}

Re: rst and pypandoc

2015-03-02 Thread MRAB
On 2015-03-02 14:08, Dave Angel wrote: On 03/02/2015 08:51 AM, alb wrote: Hi Steven, Steven D'Aprano wrote: [snip] Oh, by the way, "i" is normally a terrible variable name for a string. Not only doesn't it explain what the variable is for, but there is a very strong convention in programm

Re: rst and pypandoc

2015-03-02 Thread MRAB
On 2015-03-02 13:51, alb wrote: Hi Steven, Steven D'Aprano wrote: [] Since \r is an escape character, that will give you carriage return followed by "ef{fig:abc". The solution to that is to either escape the backslash: i = '\\ref{fig:abc}' or use a raw string: i = r'\\ref{fig:abc}' ok,

Re: rst and pypandoc

2015-03-02 Thread Dave Angel
On 03/02/2015 08:51 AM, alb wrote: Hi Steven, Steven D'Aprano wrote: [] Since \r is an escape character, that will give you carriage return followed by "ef{fig:abc". The solution to that is to either escape the backslash: i = '\\ref{fig:abc}' or use a raw string: i = r'\\ref{fig:abc}' A

Re: rst and pypandoc

2015-03-02 Thread alb
Hi Steven, Steven D'Aprano wrote: [] > Since \r is an escape character, that will give you carriage return followed > by "ef{fig:abc". > > The solution to that is to either escape the backslash: > > i = '\\ref{fig:abc}' > > > or use a raw string: > > i = r'\\ref{fig:abc}' ok, maybe I wasn't

Re: rst and pypandoc

2015-03-02 Thread alb
Hi Dave, Dave Angel 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: this is a

Re: rst and pypandoc

2015-03-02 Thread Steven D'Aprano
alb wrote: [...] > 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}' Since \r is an escape character, that will give you carriage return followed by "ef{fig:abc". The solution to that is to eit

Re: rst and pypandoc

2015-03-02 Thread Dave Angel
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 kn

Re: rst and pypandoc

2015-03-02 Thread Wolfgang Maier
On 03/02/2015 08: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. My biggest issue is with figures and references to them. We've our macro

rst and pypandoc

2015-03-02 Thread alb
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. My biggest issue is with figures and references to them. We've our macro to allocate figures so I'm forced