aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFrancesco Occhipinti <focchi.pinti@gmail.com>2018-04-26 21:17:51 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2018-04-26 12:17:51 -0700
commiteef1c211f58f0a2ffc6c500bd2158569b83fca1f (patch)
tree63612cad375a97c2ce84d4ed4174d85f74757639 /test
parentcfa4eee28bc3d6521f806bc37c937e9615d15588 (diff)
downloadpandoc-eef1c211f58f0a2ffc6c500bd2158569b83fca1f.tar.gz
RST reader: flatten nested inlines, closes #4368 (#4554)
nested inlines are not valid RST syntax, so we flatten them following some readability criteria discussed in #4368.
Diffstat (limited to 'test')
-rw-r--r--test/Tests/Writers/RST.hs24
-rw-r--r--test/writer.rst14
2 files changed, 31 insertions, 7 deletions
diff --git a/test/Tests/Writers/RST.hs b/test/Tests/Writers/RST.hs
index 29c9328f6..89ad1de48 100644
--- a/test/Tests/Writers/RST.hs
+++ b/test/Tests/Writers/RST.hs
@@ -4,10 +4,12 @@ module Tests.Writers.RST (tests) where
import Prelude
import Test.Tasty
+import Test.Tasty.HUnit
import Tests.Helpers
import Text.Pandoc
import Text.Pandoc.Arbitrary ()
import Text.Pandoc.Builder
+import Text.Pandoc.Writers.RST
infix 4 =:
(=:) :: (ToString a, ToPandoc a)
@@ -52,6 +54,17 @@ tests = [ testGroup "rubrics"
, ""
, " quoted"]
]
+ , testGroup "flatten"
+ [ testCase "emerges nested styles as expected" $
+ flatten (Emph [Str "1", Strong [Str "2"], Str "3"]) @?=
+ [Emph [Str "1"], Strong [Str "2"], Emph [Str "3"]]
+ , testCase "could introduce trailing spaces" $
+ flatten (Emph [Str "f", Space, Strong [Str "2"]]) @?=
+ [Emph [Str "f", Space], Strong [Str "2"]]
+ -- the test above is the reason why we call
+ -- stripLeadingTrailingSpace through transformNested after
+ -- flatten
+ ]
, testGroup "inlines"
[ "are removed when empty" =: -- #4434
plain (strong (str "")) =?> ""
@@ -64,6 +77,17 @@ tests = [ testGroup "rubrics"
strong (space <> str "text" <> space <> space) =?> "**text**"
, "single space stripped" =:
strong space =?> ""
+ , "give priority to strong style over emphasis" =:
+ strong (emph (strong (str "s"))) =?> "**s**"
+ , "links are not elided by outer style" =:
+ strong (emph (link "loc" "" (str "text"))) =?>
+ "`text <loc>`__"
+ , "RST inlines cannot start nor end with spaces" =:
+ emph (str "f" <> space <> strong (str "d") <> space <> str "l") =?>
+ "*f*\\ **d**\\ *l*"
+ , "keeps quotes" =:
+ strong (str "f" <> doubleQuoted (str "d") <> str "l") =?>
+ "**f“d”l**"
]
, testGroup "headings"
[ "normal heading" =:
diff --git a/test/writer.rst b/test/writer.rst
index 3353d11d3..0c986b887 100644
--- a/test/writer.rst
+++ b/test/writer.rst
@@ -615,21 +615,21 @@ This is *emphasized*, and so *is this*.
This is **strong**, and so **is this**.
-An *`emphasized link </url>`__*.
+An `emphasized link </url>`__.
-***This is strong and em.***
+**This is strong and em.**
-So is ***this*** word.
+So is **this** word.
-***This is strong and em.***
+**This is strong and em.**
-So is ***this*** word.
+So is **this** word.
This is code: ``>``, ``$``, ``\``, ``\$``, ``<html>``.
-[STRIKEOUT:This is *strikeout*.]
+[STRIKEOUT:This is strikeout.]
-Superscripts: a\ :sup:`bc`\ d a\ :sup:`*hello*` a\ :sup:`hello there`.
+Superscripts: a\ :sup:`bc`\ d a\ :sup:`hello` a\ :sup:`hello there`.
Subscripts: H\ :sub:`2`\ O, H\ :sub:`23`\ O, H\ :sub:`many of them`\ O.