git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: pass through macro defs in rawLaTeXBlock...

even if the `latex_macros` extension is set. This reverts to earlier behavior and is probably safer on the whole, since some macros only modify things in included packages, which pandoc's macro expansion can't modify. Closes #4246.

commite7d95cadf537909bcb1e7d17d4545932d6bb34bc authorJohn MacFarlane <jgm@berkeley.edu> dateSat 13 Jan 2018, 22:12 (9 years ago) parent4855354
4 files changed+8−5
src/Text/Pandoc/Readers/LaTeX.hs+2−4 test/command/4159.md+2−1 test/command/macros.md+3 test/markdown-reader-more.native+1
src/Text/Pandoc/Readers/LaTeX.hs+2−4
@@ -272,10 +272,8 @@ rawLaTeXBlock = do
272272 lookAhead (try (char '\\' >> letter))
273273 -- we don't want to apply newly defined latex macros to their own
274274 -- definitions:
275− (do (_, raw) <- rawLaTeXParser macroDef
276− (guardDisabled Ext_latex_macros >> return raw) <|> return "")
277− <|> (do (_, raw) <- rawLaTeXParser (environment <|> blockCommand)
278− applyMacros raw)
275+ (snd <$> rawLaTeXParser macroDef)
276+ <|> ((snd <$> rawLaTeXParser (environment <|> blockCommand)) >>= applyMacros)
279277
280278rawLaTeXInline :: (PandocMonad m, HasMacros s, HasReaderOptions s)
281279 => ParserT String s m String
test/command/4159.md+2−1
@@ -3,5 +3,6 @@
33\newcommand{\gen}{a\ Gen\ b}
44abc
55^D
6−[Para [Str "abc"]]
6+[RawBlock (Format "latex") "\\newcommand{\\gen}{a\\ Gen\\ b}"
7+,Para [Str "abc"]]
78```
test/command/macros.md+3
@@ -3,6 +3,7 @@
33\newcommand{\my}{\phi}
44$\my+\my$
55^D
6+\newcommand{\my}{\phi}
67$\phi+\phi$
78```
89
@@ -73,6 +74,7 @@ x &= y\\\end{aligned}\]
7374\my+\my
7475\end{equation}
7576^D
77+\newcommand{\my}{\phi}
7678\begin{equation}
7779\phi+\phi
7880\end{equation}
@@ -96,5 +98,6 @@ x &= y\\\end{aligned}\]
9698\newcommand{\my}{\emph{a}}
9799\my
98100^D
101+\newcommand{\my}{\emph{a}}
99102\emph{a}
100103```
test/markdown-reader-more.native+1
@@ -54,6 +54,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "Author",S
5454,OrderedList (3,Example,TwoParens)
5555 [[Plain [Str "Third",Space,Str "example."]]]
5656,Header 2 ("macros",[],[]) [Str "Macros"]
57+,RawBlock (Format "latex") "\\newcommand{\\tuple}[1]{\\langle #1 \\rangle}"
5758,Para [Math InlineMath "\\langle x,y \\rangle"]
5859,Header 2 ("case-insensitive-references",[],[]) [Str "Case-insensitive",Space,Str "references"]
5960,Para [Link ("",[],[]) [Str "Fum"] ("/fum","")]