public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* How to use LaTeX command "\write18{}" in Pandoc
@ 2017-07-12  8:10 sven.androd-Re5JQEeQqe8AvxtiuMwx3w
       [not found] ` <9a1c3693-5d46-4de0-921b-3408ca893bad-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: sven.androd-Re5JQEeQqe8AvxtiuMwx3w @ 2017-07-12  8:10 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 2934 bytes --]

Hi everyone! 

I'm using the LaTeX command "\write18{}" to be able to issue commands 
directly when compiling the document. However, when I'm trying to convert 
from Markdown to LaTeX, the "write18 {}" command gets escaped and therefore 
can't be processed by LaTeX.

Example (Markdown file, temp.md):
# This is a section
Capturing the output of a command with `write18`.

## Description
Some examples where the content does not get escaped:

\section{git --version}

\input{git --version}

\write{git --version}

Some examples where the content gets escaped:

\immediate\write18{git --version}

\write18{git --version}

This gets compiled down to (pandoc --to latex temp.md)
\section{This is a section}\label{this-is-a-section}

Capturing the output of a command with \texttt{write18}.

\subsection{Description}\label{description}

Some examples where the content does not get escaped:

\section{git --version}

\input{git --version}

\write{git --version}

Some examples where the content gets escaped:

\immediate\write18\{git --version\}

\write18\{git --version\}


As you can see, the "\write18{git --version}" command gets compiled down to 
"\write18\{git --version\}" that's escaped and therefore cannot be 
processed by LaTeX.
This seems to have something to do with the Markdown reader, since if you 
print out the JSON AST, each input gets treated separately. 

Output of "pandoc --to json temp.md | python -m json.tool"
...
        {
            "c": [
                {
                    "c": [
                        "tex",
                        "\\write"
                    ],
                    "t": "RawInline"
                },
                {
                    "c": "18{git",
                    "t": "Str"
                },
                {
                    "t": "Space"
                },
                {
                    "c": "--version}",
                    "t": "Str"
                }
            ],
            "t": "Para"
        }
...


*Now to my actual question: is this expected behavior or some kind of 
missing token definition? And if so; how would I work around it? *I'd 
rather not write a Pandoc filter that would process the entire AST, but if 
the above behavior is expected I guess that's a solution that could work. 
Otherwise, does anyone else have any suggestions?

Thank you

Best regards,
Sven

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/9a1c3693-5d46-4de0-921b-3408ca893bad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 20210 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-07-15 11:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-12  8:10 How to use LaTeX command "\write18{}" in Pandoc sven.androd-Re5JQEeQqe8AvxtiuMwx3w
     [not found] ` <9a1c3693-5d46-4de0-921b-3408ca893bad-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-07-12 11:43   ` John MacFarlane
     [not found]     ` <20170712114354.GA21458-jF64zX8BO091tJRe0FUodcM6rOWSkUom@public.gmane.org>
2017-07-12 12:04       ` sven.androd-Re5JQEeQqe8AvxtiuMwx3w
2017-07-13 14:31     ` Ulrike Fischer
     [not found]       ` <xrwf1rqnc3pu.dlg-bMiYgyzgJ3Ab1SvskN2V4Q@public.gmane.org>
2017-07-15 11:22         ` sven.androd-Re5JQEeQqe8AvxtiuMwx3w

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).