git.iko.soy/typeable/pandoc
on master help sign in
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`.

commit65cc909fdee4dbc93ba0cf1c04ff64780caae57e authorFrancesco Occhipinti <focchi.pinti@gmail.com> dateSun 18 Mar 2018, 03:21 (9 years ago) parent59903ec
3 files changed+13−1
src/Text/Pandoc/Writers/RST.hs+3−1 src/Text/Pandoc/Writers/Shared.hs+1 test/Tests/Writers/RST.hs+9
src/Text/Pandoc/Writers/RST.hs+3−1
@@ -379,7 +379,9 @@ blockListToRST = blockListToRST' False
379379-- | Convert list of Pandoc inline elements to RST.
380380inlineListToRST :: PandocMonad m => [Inline] -> RST m Doc
381381inlineListToRST lst =
382− mapM inlineToRST (removeSpaceAfterDisplayMath $ insertBS lst) >>=
382+ mapM inlineToRST ((stripLeadingTrailingSpace .
383+ removeSpaceAfterDisplayMath .
384+ insertBS) lst) >>=
383385 return . hcat
384386 where -- remove spaces after displaymath, as they screw up indentation:
385387 removeSpaceAfterDisplayMath (Math DisplayMath x : zs) =
src/Text/Pandoc/Writers/Shared.hs+1
@@ -41,6 +41,7 @@ module Text.Pandoc.Writers.Shared (
4141 , unsmartify
4242 , gridTable
4343 , metaValueToInlines
44+ , stripLeadingTrailingSpace
4445 )
4546where
4647import Control.Monad (zipWithM)
test/Tests/Writers/RST.hs+9
@@ -50,6 +50,15 @@ tests = [ testGroup "rubrics"
5050 , ""
5151 , " quoted"]
5252 ]
53+ , testGroup "spaces are stripped within inlines"
54+ -- pandoc issue 4327 "The text within inline markup may not
55+ -- begin or end with whitespace"
56+ -- http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup
57+ [ "multiple" =:
58+ strong (space <> str "text" <> space <> space) =?> "**text**"
59+ , "single" =:
60+ strong (space) =?> "****"
61+ ]
5362 , testGroup "headings"
5463 [ "normal heading" =:
5564 header 1 (text "foo") =?>