aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/LaTeX.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-06-04 21:20:11 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-06-04 21:20:11 -0700
commit10615420dec27756baa2d4a6881d00c2e28d9cc1 (patch)
tree762ae8108f0d87639c1ad48d999c84e7fbd7750b /src/Text/Pandoc/Readers/LaTeX.hs
parentad9770fe86d0f7d9e8ccfe09eada1e7a60ef3d25 (diff)
downloadpandoc-10615420dec27756baa2d4a6881d00c2e28d9cc1.tar.gz
Include trailing {}s in raw latex commands.
Change is in rawLaTeXInline in LaTeX reader, but it affects the markdown reader and other readers that allow raw LaTeX. Previously, trailing `{}` would be included for unknown commands, but not for known commands. However, they are sometimes used to avoid a trailing space after the command. The chances that a `{}` after a LaTeX command is not part of the command are very small. Closes #5439.
Diffstat (limited to 'src/Text/Pandoc/Readers/LaTeX.hs')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 6aa0f1205..4f24dd3d0 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -155,10 +155,15 @@ rawLaTeXInline :: (PandocMonad m, HasMacros s, HasReaderOptions s)
=> ParserT String s m String
rawLaTeXInline = do
lookAhead (try (char '\\' >> letter))
- snd <$> ( rawLaTeXParser True
+ raw <- snd <$>
+ ( rawLaTeXParser True
(mempty <$ (controlSeq "input" >> skipMany opt >> braced))
inlines
- <|> rawLaTeXParser True (inlineEnvironment <|> inlineCommand') inlines)
+ <|> rawLaTeXParser True (inlineEnvironment <|> inlineCommand')
+ inlines
+ )
+ finalbraces <- mconcat <$> many (try (string "{}")) -- see #5439
+ return $ raw <> finalbraces
inlineCommand :: PandocMonad m => ParserT String ParserState m Inlines
inlineCommand = do