diff options
| author | John MacFarlane <[email protected]> | 2022-07-18 19:52:33 +0200 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2022-07-18 19:52:33 +0200 |
| commit | e90ce8e1ab4dc0fc441c59ea53cfd2733f587e96 (patch) | |
| tree | 6eab4e8be510d7a049af1d8085228f14523c6ddf /src | |
| parent | dfbfbfbf2467ab7dff0ae2394ce0631540fae089 (diff) | |
Unescape characters in `\lstinline` inside `\passthrough`.
For full motivation, see #1629 ; this improves on
99e24cf18337b0b460005bf77e367783c34b75e7.
Closes #8179.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 13 |
1 files changed, 12 insertions, 1 deletions
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 |
