Unescape characters in \lstinline
inside \passthrough
.
For full motivation, see #1629 ; this improves on
99e24cf183
.
Closes #8179.
This commit is contained in:
parent
dfbfbfbf24
commit
e90ce8e1ab
2 changed files with 18 additions and 1 deletions
|
@ -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
|
||||
|
|
6
test/command/8179.md
Normal file
6
test/command/8179.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
```
|
||||
% pandoc -f latex -t native
|
||||
\passthrough{\lstinline!\\textbf\{\}!}
|
||||
^D
|
||||
[ Para [ Code ( "" , [] , [] ) "\\textbf{}" ] ]
|
||||
```
|
Loading…
Reference in a new issue