diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 988cc3055..f3aa29490 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -382,7 +382,8 @@ inlineCommands = M.unions , ("lowercase", makeLowercase <$> tok) , ("thanks", skipopts >> note <$> grouped block) , ("footnote", skipopts >> footnote) - , ("passthrough", tok) -- \passthrough macro used by latex writer + , ("passthrough", fixPassthroughEscapes <$> tok) + -- \passthrough macro used by latex writer -- for listings , ("includegraphics", do options <- option [] keyvals src <- braced @@ -473,6 +474,16 @@ alterStr :: (Text -> Text) -> Inline -> Inline alterStr f (Str xs) = Str (f xs) alterStr _ x = x +fixPassthroughEscapes :: Inlines -> Inlines +fixPassthroughEscapes = walk go + where + go (Code attr txt) = Code attr (T.pack $ unescapePassthrough $ T.unpack txt) + go x = x + unescapePassthrough [] = [] + unescapePassthrough ('\\':c:cs) + | c `elem` ['%','{','}','\\'] = c : unescapePassthrough cs + unescapePassthrough (c:cs) = c : unescapePassthrough cs + hyperlink :: PandocMonad m => LP m Inlines hyperlink = try $ do src <- untokenize <$> braced diff --git a/test/command/8179.md b/test/command/8179.md new file mode 100644 index 000000000..ef7361878 --- /dev/null +++ b/test/command/8179.md @@ -0,0 +1,6 @@ +``` +% pandoc -f latex -t native +\passthrough{\lstinline!\\textbf\{\}!} +^D +[ Para [ Code ( "" , [] , [] ) "\\textbf{}" ] ] +```