mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-28 03:06:30 +00:00
Unescape characters in \lstinline inside \passthrough.
For full motivation, see #1629 ; this improves on
99e24cf183.
Closes #8179.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
```
|
||||
% pandoc -f latex -t native
|
||||
\passthrough{\lstinline!\\textbf\{\}!}
|
||||
^D
|
||||
[ Para [ Code ( "" , [] , [] ) "\\textbf{}" ] ]
|
||||
```
|
||||
Reference in New Issue
Block a user