summaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-10-16 20:54:43 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2017-10-16 20:54:43 -0700
commit9cf9a64923c672fafd1458bda6f643ada83e2b1e (patch)
tree270136da5670107f60903c065d10438f3b11a6d4 /src/Text
parentcba18c19a69d05ecd3e617bcbd74780482bffd7e (diff)
RST writer: correctly handle inline code containing backticks.
(Use a :literal: role.) Closes #3974.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/RST.hs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs
index cd277b51b..8599680cf 100644
--- a/src/Text/Pandoc/Writers/RST.hs
+++ b/src/Text/Pandoc/Writers/RST.hs
@@ -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 $