RST writer: strip whitespace within inlines, closes #4327 (#4329)

+ Whitespace is ignored at the beginning and end of emphasis, as per
  <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup>.
+ Export `stripLeadingTrailingSpace` from `Text.Pandoc.Writers.Shared`.
This commit is contained in:
Francesco Occhipinti
2018-03-17 19:21:27 -07:00
committed by John MacFarlane
parent 59903ec82c
commit 65cc909fde
3 changed files with 13 additions and 1 deletions
+3 -1
View File
@@ -379,7 +379,9 @@ blockListToRST = blockListToRST' False
-- | Convert list of Pandoc inline elements to RST.
inlineListToRST :: PandocMonad m => [Inline] -> RST m Doc
inlineListToRST lst =
mapM inlineToRST (removeSpaceAfterDisplayMath $ insertBS lst) >>=
mapM inlineToRST ((stripLeadingTrailingSpace .
removeSpaceAfterDisplayMath .
insertBS) lst) >>=
return . hcat
where -- remove spaces after displaymath, as they screw up indentation:
removeSpaceAfterDisplayMath (Math DisplayMath x : zs) =
+1
View File
@@ -41,6 +41,7 @@ module Text.Pandoc.Writers.Shared (
, unsmartify
, gridTable
, metaValueToInlines
, stripLeadingTrailingSpace
)
where
import Control.Monad (zipWithM)
+9
View File
@@ -50,6 +50,15 @@ tests = [ testGroup "rubrics"
, ""
, " quoted"]
]
, testGroup "spaces are stripped within inlines"
-- pandoc issue 4327 "The text within inline markup may not
-- begin or end with whitespace"
-- http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup
[ "multiple" =:
strong (space <> str "text" <> space <> space) =?> "**text**"
, "single" =:
strong (space) =?> "****"
]
, testGroup "headings"
[ "normal heading" =:
header 1 (text "foo") =?>