RST writer: correctly handle inline code containing backticks.
(Use a :literal: role.) Closes #3974.
This commit is contained in:
parent
cba18c19a6
commit
9cf9a64923
2 changed files with 13 additions and 2 deletions
|
@ -483,10 +483,15 @@ inlineToRST (Quoted DoubleQuote lst) = do
|
|||
else return $ "“" <> contents <> "”"
|
||||
inlineToRST (Cite _ lst) =
|
||||
inlineListToRST lst
|
||||
inlineToRST (Code _ str) =
|
||||
inlineToRST (Code _ str) = do
|
||||
opts <- gets stOptions
|
||||
-- we trim the string because the delimiters must adjoin a
|
||||
-- non-space character; see #3496
|
||||
return $ "``" <> text (trim str) <> "``"
|
||||
-- we use :literal: when the code contains backticks, since
|
||||
-- :literal: allows backslash-escapes; see #3974
|
||||
return $ if '`' `elem` str
|
||||
then ":literal:`" <> text (escapeString opts (trim str)) <> "`"
|
||||
else "``" <> text (trim str) <> "``"
|
||||
inlineToRST (Str str) = do
|
||||
opts <- gets stOptions
|
||||
return $ text $
|
||||
|
|
6
test/command/3974.md
Normal file
6
test/command/3974.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
```
|
||||
% pandoc -f native -t rst
|
||||
[Code ("",[],[]) "``"]
|
||||
^D
|
||||
:literal:`\`\``
|
||||
```
|
Loading…
Add table
Reference in a new issue