From 10615420dec27756baa2d4a6881d00c2e28d9cc1 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Tue, 4 Jun 2019 21:20:11 -0700 Subject: [PATCH] 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 +++++++-- test/command/5439.md | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 test/command/5439.md 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 diff --git a/test/command/5439.md b/test/command/5439.md new file mode 100644 index 000000000..b021161fd --- /dev/null +++ b/test/command/5439.md @@ -0,0 +1,6 @@ +``` +% pandoc -t latex +namespace\fshyp{}container +^D +namespace\fshyp{}container +```