git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: fix bug parsing macro arguments.

If `\cL` is defined as `\mathcal{L}`, and `\til` as `\tilde{#1}`, then `\til\cL` should expand to `\tilde{\mathcal{L}}`, but pandoc was expanding it to `\tilde\mathcal{L}`. This is fixed by parsing the arguments in "verbatim mode" when the macro expands arguments at the point of use. Closes #6796.

commit6cbe5efd5628ddd67f4e17d75a3c3370f53b0e87 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 2 Nov 2020, 15:04 (6 years ago) parent5760cd8
2 files changed+21−1
src/Text/Pandoc/Readers/LaTeX/Parsing.hs+5−1 test/command/6796.md+16
src/Text/Pandoc/Readers/LaTeX/Parsing.hs+5−1
@@ -484,7 +484,11 @@ doMacros' n inp =
484484 Nothing -> mzero
485485 Just (Macro expansionPoint argspecs optarg newtoks) -> do
486486 let getargs' = do
487− args <- case optarg of
487+ args <-
488+ (case expansionPoint of
489+ ExpandWhenUsed -> withVerbatimMode
490+ ExpandWhenDefined -> id)
491+ $ case optarg of
488492 Nothing -> getargs M.empty argspecs
489493 Just o -> do
490494 x <- option o bracketedToks
test/command/6796.mdnew file+16
@@ -0,0 +1,16 @@
1+```
2+% pandoc -f latex -t markdown
3+\newcommand{\cL}{\mathcal{L}}
4+\newcommand{\til}[1]{\tilde{#1}}
5+
6+$$\til\cL$$
7+
8+\newcommand{\mc}[1]{\mathcal{#1}}
9+\newcommand{\dL}{\mc{L}}
10+
11+$$\til\dL$$
12+^D
13+$$\tilde{\mathcal{L}}$$
14+
15+$$\tilde{\mathcal{L}}$$
16+```