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
This commit is contained in:
Albert Krewinkel
2019-11-14 14:28:30 +01:00
parent 8ff7fd484f
commit e43c2e75a1
2 changed files with 5 additions and 2 deletions
+2 -2
View File
@@ -462,7 +462,7 @@ transformInlines = insertBS .
okBeforeComplex Space = True
okBeforeComplex SoftBreak = True
okBeforeComplex LineBreak = True
okBeforeComplex (Str (T.uncons -> Just (c,_)))
okBeforeComplex (Str (T.unsnoc -> Just (_,c)))
= isSpace c || c `elemText` "-:/'\"<([{–—"
okBeforeComplex _ = False
isComplex :: Inline -> Bool
@@ -491,7 +491,7 @@ flatten outer
combineAll = foldl combine []
combine :: [Inline] -> Inline -> [Inline]
combine f i =
combine f i =
case (outer, i) of
-- quotes are not rendered using RST inlines, so we can keep
-- them and they will be readable and parsable
+3
View File
@@ -105,6 +105,9 @@ tests = [ testGroup "rubrics"
, "keeps quotes" =:
strong (str "f" <> doubleQuoted (str "d") <> str "l") =?>
"**f“d”l**"
, "backslash inserted between str and code" =:
str "/api?query=" <> code "foo" =?>
"/api?query=\\ ``foo``"
]
, testGroup "headings"
[ "normal heading" =: