Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latex macro in markdown input mangled in latex output #554

Closed
shvenkat opened this issue Jun 30, 2012 · 3 comments
Closed

Latex macro in markdown input mangled in latex output #554

shvenkat opened this issue Jun 30, 2012 · 3 comments

Comments

@shvenkat
Copy link

I'm using pandoc 1.9.4.2 to convert markdown (with pandoc extensions) to latex. Pandoc mangles the macro with backslash escapes but only if the macro takes arguments. This does not happen if the output format is not latex.

input.md contains:

\newcommand{\plus}[2]{#1 + #2}
$\plus{3}{4}$

"pandoc -f markdown -t latex < input.md" gives:

\newcommand{\plus}

{[}2{]}\{\#1 + \#2\} $\plus{3}{4}$

"pandoc -f markdown -t plain < input.md" gives:

3 + 4
@jgm
Copy link
Owner

jgm commented Jun 30, 2012

Hm, surprising and undesirable. I see why it is doing this.
src/pandoc.hs sets stateApplyMacros to False if output is latex;
the idea is that latex can apply its own macros. So far so good.
But this also disables macro parsing in the reader, leaving
\newcommand... to be parsed by the markdown reader. I still need
to look into why the whole \newcommand... with its arguments is not
being parsed correctly.

+++ Shiv Venkatasubrahmanyam [Jun 29 12 17:46 ]:

I'm using pandoc 1.9.4.2 to convert markdown (with pandoc extensions) to latex. Pandoc mangles the macro with backslash escapes but only if the macro takes arguments. This does not happen if the output format is not latex.

input.md contains:
\newcommand{\plus}[2]{#1 + #2}
$\plus{3}{4}$

"pandoc -f markdown -t latex < input.md" gives:
\newcommand{\plus}

{[}2{]}\{\#1 + \#2\} $\plus{3}{4}$

"pandoc -f markdown -t plain < input.md" gives:
3 + 4


Reply to this email directly or view it on GitHub:
#554

@jgm jgm closed this as completed in 9d5230c Jun 30, 2012
@kennknowles
Copy link

This fix was authored 7 months ago, while 1.9.4.5 was released 3 months ago, yet I get the same behavior.

Using the example from the User's Guide:

\newcommand{\tuple}[1]{\langle #1 \rangle}

$\tuple{a, b, c}$
$ pandoc --to=latex test.md
\newcommand{\tuple}

{[}1{]}\{\langle \#1 \rangle\} $\tuple{a, b, c}$
$ pandoc test.md  --to=html
<p><span class="math">⟨<em>a</em>, <em>b</em>, <em>c</em>⟩</span></p>

Is this a regression or have I got something wrong or out of date?

@njbart
Copy link

njbart commented Jan 27, 2013

This issue is still there: With test.txt containing:

\newcommand{\tuple}[1]{\langle #1 \rangle}
\renewcommand{\tuple}[1]{\langle #1 \rangle}
\providecommand{\tuple}[1]{\langle #1 \rangle}

$\tuple{a, b, c}$

command line: pandoc -t latex test.txt (pandoc 1.10.0.5)

gives:

\providecommand{\tuple}{[}1{]}\{\langle \#1 \rangle\}

$\tuple{a, b, c}$

jgm added a commit that referenced this issue Jun 3, 2019
e.g. ordered list item, in Markdown writer.

Closes #554.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants