git.iko.soy/typeable/pandoc
on master help sign in
RST writer: strip whitespace within inlines, closes #4327 (#4329)
65cc909Francesco Occhipinti
src/Text/Pandoc/Writers/RST.hs+3−1
@@ -379,7 +379,9 @@ blockListToRST = blockListToRST' False
379-- | Convert list of Pandoc inline elements to RST.
379-- | Convert list of Pandoc inline elements to RST.
380inlineListToRST :: PandocMonad m => [Inline] -> RST m Doc
380inlineListToRST :: PandocMonad m => [Inline] -> RST m Doc
381inlineListToRST lst =
381inlineListToRST lst =
382+ mapM inlineToRST ((stripLeadingTrailingSpace .
382− mapM inlineToRST (removeSpaceAfterDisplayMath $ insertBS lst) >>=
383+ removeSpaceAfterDisplayMath .
384+ insertBS) lst) >>=
383 return . hcat
385 return . hcat
384 where -- remove spaces after displaymath, as they screw up indentation:
386 where -- remove spaces after displaymath, as they screw up indentation:
385 removeSpaceAfterDisplayMath (Math DisplayMath x : zs) =
387 removeSpaceAfterDisplayMath (Math DisplayMath x : zs) =
src/Text/Pandoc/Writers/Shared.hs+1
@@ -41,6 +41,7 @@ module Text.Pandoc.Writers.Shared (
41 , unsmartify
41 , unsmartify
42 , gridTable
42 , gridTable
43 , metaValueToInlines
43 , metaValueToInlines
44+ , stripLeadingTrailingSpace
44 )
45 )
45where
46where
46import Control.Monad (zipWithM)
47import Control.Monad (zipWithM)
test/Tests/Writers/RST.hs+9
@@ -50,6 +50,15 @@ tests = [ testGroup "rubrics"
50 , ""
50 , ""
51 , " quoted"]
51 , " quoted"]
52 ]
52 ]
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+ ]
53 , testGroup "headings"
62 , testGroup "headings"
54 [ "normal heading" =:
63 [ "normal heading" =:
55 header 1 (text "foo") =?>
64 header 1 (text "foo") =?>