diff options
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 6 | ||||
-rw-r--r-- | test/command/4159.md | 3 | ||||
-rw-r--r-- | test/command/macros.md | 3 | ||||
-rw-r--r-- | test/markdown-reader-more.native | 1 |
4 files changed, 8 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index d3f730259..0a78fbe53 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -272,10 +272,8 @@ rawLaTeXBlock = do lookAhead (try (char '\\' >> letter)) -- we don't want to apply newly defined latex macros to their own -- definitions: - (do (_, raw) <- rawLaTeXParser macroDef - (guardDisabled Ext_latex_macros >> return raw) <|> return "") - <|> (do (_, raw) <- rawLaTeXParser (environment <|> blockCommand) - applyMacros raw) + (snd <$> rawLaTeXParser macroDef) + <|> ((snd <$> rawLaTeXParser (environment <|> blockCommand)) >>= applyMacros) rawLaTeXInline :: (PandocMonad m, HasMacros s, HasReaderOptions s) => ParserT String s m String diff --git a/test/command/4159.md b/test/command/4159.md index 81deba53a..4881edcc5 100644 --- a/test/command/4159.md +++ b/test/command/4159.md @@ -3,5 +3,6 @@ \newcommand{\gen}{a\ Gen\ b} abc ^D -[Para [Str "abc"]] +[RawBlock (Format "latex") "\\newcommand{\\gen}{a\\ Gen\\ b}" +,Para [Str "abc"]] ``` diff --git a/test/command/macros.md b/test/command/macros.md index 4bd2eb00a..9de87e7a0 100644 --- a/test/command/macros.md +++ b/test/command/macros.md @@ -3,6 +3,7 @@ \newcommand{\my}{\phi} $\my+\my$ ^D +\newcommand{\my}{\phi} $\phi+\phi$ ``` @@ -73,6 +74,7 @@ x &= y\\\end{aligned}\] \my+\my \end{equation} ^D +\newcommand{\my}{\phi} \begin{equation} \phi+\phi \end{equation} @@ -96,5 +98,6 @@ x &= y\\\end{aligned}\] \newcommand{\my}{\emph{a}} \my ^D +\newcommand{\my}{\emph{a}} \emph{a} ``` diff --git a/test/markdown-reader-more.native b/test/markdown-reader-more.native index 742b6187c..5f34c7927 100644 --- a/test/markdown-reader-more.native +++ b/test/markdown-reader-more.native @@ -54,6 +54,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "Author",S ,OrderedList (3,Example,TwoParens) [[Plain [Str "Third",Space,Str "example."]]] ,Header 2 ("macros",[],[]) [Str "Macros"] +,RawBlock (Format "latex") "\\newcommand{\\tuple}[1]{\\langle #1 \\rangle}" ,Para [Math InlineMath "\\langle x,y \\rangle"] ,Header 2 ("case-insensitive-references",[],[]) [Str "Case-insensitive",Space,Str "references"] ,Para [Link ("",[],[]) [Str "Fum"] ("/fum","")] |