aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Occhipinti <focchi.pinti@gmail.com>2018-03-18 03:21:27 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2018-03-17 19:21:27 -0700
commit65cc909fdee4dbc93ba0cf1c04ff64780caae57e (patch)
tree8581700724f3588c90d57ae50d86080818ab687a
parent59903ec82c20d1a8390c06108004cce9bb6fa70d (diff)
downloadpandoc-65cc909fdee4dbc93ba0cf1c04ff64780caae57e.tar.gz
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`.
-rw-r--r--src/Text/Pandoc/Writers/RST.hs4
-rw-r--r--src/Text/Pandoc/Writers/Shared.hs1
-rw-r--r--test/Tests/Writers/RST.hs9
3 files changed, 13 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs
index 95cb46643..91bc9d66a 100644
--- a/src/Text/Pandoc/Writers/RST.hs
+++ b/src/Text/Pandoc/Writers/RST.hs
@@ -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) =
diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs
index ae4cc5cc5..5c3469d4d 100644
--- a/src/Text/Pandoc/Writers/Shared.hs
+++ b/src/Text/Pandoc/Writers/Shared.hs
@@ -41,6 +41,7 @@ module Text.Pandoc.Writers.Shared (
, unsmartify
, gridTable
, metaValueToInlines
+ , stripLeadingTrailingSpace
)
where
import Control.Monad (zipWithM)
diff --git a/test/Tests/Writers/RST.hs b/test/Tests/Writers/RST.hs
index 4c0a926bb..b8778f995 100644
--- a/test/Tests/Writers/RST.hs
+++ b/test/Tests/Writers/RST.hs
@@ -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") =?>