git.iko.soy/typeable/pandoc
on master help sign in
RST writer: fix backslash escaping after strings

The check whether a complex inline element following a string must be escaped, now depends on the last character of the string instead of the first. Fixes: #5906

commite43c2e75a1284f464ce1ef9b3b6e12ea2b645f4a authorAlbert Krewinkel <albert@zeitkraut.de> dateThu 14 Nov 2019, 14:28 (7 years ago) parent8ff7fd4
2 files changed+5−2
src/Text/Pandoc/Writers/RST.hs+2−2 test/Tests/Writers/RST.hs+3
src/Text/Pandoc/Writers/RST.hs+2−2
@@ -462,7 +462,7 @@ transformInlines = insertBS .
462462 okBeforeComplex Space = True
463463 okBeforeComplex SoftBreak = True
464464 okBeforeComplex LineBreak = True
465− okBeforeComplex (Str (T.uncons -> Just (c,_)))
465+ okBeforeComplex (Str (T.unsnoc -> Just (_,c)))
466466 = isSpace c || c `elemText` "-:/'\"<([{–—"
467467 okBeforeComplex _ = False
468468 isComplex :: Inline -> Bool
@@ -491,7 +491,7 @@ flatten outer
491491 combineAll = foldl combine []
492492
493493 combine :: [Inline] -> Inline -> [Inline]
494− combine f i =
494+ combine f i =
495495 case (outer, i) of
496496 -- quotes are not rendered using RST inlines, so we can keep
497497 -- them and they will be readable and parsable
test/Tests/Writers/RST.hs+3
@@ -105,6 +105,9 @@ tests = [ testGroup "rubrics"
105105 , "keeps quotes" =:
106106 strong (str "f" <> doubleQuoted (str "d") <> str "l") =?>
107107 "**f“d”l**"
108+ , "backslash inserted between str and code" =:
109+ str "/api?query=" <> code "foo" =?>
110+ "/api?query=\\ ``foo``"
108111 ]
109112 , testGroup "headings"
110113 [ "normal heading" =: