From 10615420dec27756baa2d4a6881d00c2e28d9cc1 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 4 Jun 2019 21:20:11 -0700 Subject: 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. --- src/Text/Pandoc/Readers/LaTeX.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Readers/LaTeX.hs') 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 -- cgit v1.2.3