diff options
author | Francesco Occhipinti <focchi.pinti@gmail.com> | 2018-04-26 21:17:51 +0200 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-04-26 12:17:51 -0700 |
commit | eef1c211f58f0a2ffc6c500bd2158569b83fca1f (patch) | |
tree | 63612cad375a97c2ce84d4ed4174d85f74757639 /test/Tests | |
parent | cfa4eee28bc3d6521f806bc37c937e9615d15588 (diff) | |
download | pandoc-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/Tests')
-rw-r--r-- | test/Tests/Writers/RST.hs | 24 |
1 files changed, 24 insertions, 0 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" =: |