aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-11-02 15:04:16 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2020-11-02 15:04:16 -0800
commit6cbe5efd5628ddd67f4e17d75a3c3370f53b0e87 (patch)
treea9f5441c05876f9b86ed6e93e6de95e36aaf17df /src/Text/Pandoc/Readers/LaTeX/Parsing.hs
parent5760cd850fd36ab483dceb5bfc78928d36ccee63 (diff)
downloadpandoc-6cbe5efd5628ddd67f4e17d75a3c3370f53b0e87.tar.gz
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.
Diffstat (limited to 'src/Text/Pandoc/Readers/LaTeX/Parsing.hs')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX/Parsing.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
index 6d6d4f3ec..09f332bb8 100644
--- a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
+++ b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
@@ -484,7 +484,11 @@ doMacros' n inp =
Nothing -> mzero
Just (Macro expansionPoint argspecs optarg newtoks) -> do
let getargs' = do
- args <- case optarg of
+ args <-
+ (case expansionPoint of
+ ExpandWhenUsed -> withVerbatimMode
+ ExpandWhenDefined -> id)
+ $ case optarg of
Nothing -> getargs M.empty argspecs
Just o -> do
x <- option o bracketedToks