diff options
author | Alexander Krotov <ilabdsf@gmail.com> | 2018-09-11 11:49:11 +0300 |
---|---|---|
committer | Alexander Krotov <ilabdsf@gmail.com> | 2018-09-11 11:49:11 +0300 |
commit | 165a61095c08794d1639a683f1c6f1a82387c8d5 (patch) | |
tree | 79cedf8f5eb22346bb9fb585d3783df3fd6ad384 | |
parent | cb28cab489279c48f0afd7113a75ccd96f43eaba (diff) | |
download | pandoc-165a61095c08794d1639a683f1c6f1a82387c8d5.tar.gz |
Muse writer: check for whitespace in the beginning and end of Str's
-rw-r--r-- | src/Text/Pandoc/Writers/Muse.hs | 2 | ||||
-rw-r--r-- | test/Tests/Writers/Muse.hs | 3 |
2 files changed, 5 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs index 262d4fb50..025114a47 100644 --- a/src/Text/Pandoc/Writers/Muse.hs +++ b/src/Text/Pandoc/Writers/Muse.hs @@ -415,11 +415,13 @@ fixNotes (x:xs) = x : fixNotes xs startsWithSpace :: [Inline] -> Bool startsWithSpace (Space:_) = True startsWithSpace (SoftBreak:_) = True +startsWithSpace (Str s:_) = stringStartsWithSpace s startsWithSpace _ = False endsWithSpace :: [Inline] -> Bool endsWithSpace [Space] = True endsWithSpace [SoftBreak] = True +endsWithSpace [Str s] = stringStartsWithSpace $ reverse s endsWithSpace (_:xs) = endsWithSpace xs endsWithSpace [] = False diff --git a/test/Tests/Writers/Muse.hs b/test/Tests/Writers/Muse.hs index a8ccd6d87..4cb7618f3 100644 --- a/test/Tests/Writers/Muse.hs +++ b/test/Tests/Writers/Muse.hs @@ -382,6 +382,9 @@ tests = [ testGroup "block elements" , "strong empty string" =: strong (str "") =?> "<strong></strong>" , "strong emphasized empty string" =: strong (emph (str "")) =?> "**<em></em>**" , "emphasized strong empty string" =: emph (strong (str "")) =?> "*<strong></strong>*" + , "emphasized string with space" =: emph (str " ") =?> "<em> </em>" + , "emphasized string ending with space" =: emph (str "foo ") =?> "<em>foo </em>" + , "emphasized string with tab" =: emph (str "\t") =?> "<em>\t</em>" , "emphasized space between empty strings" =: emph (str "" <> space <> str "") =?> "<em> </em>" , "strong" =: strong (text "foo") =?> "**foo**" , "strong inside word" =: text "foo" <> strong (text "bar") <> text "baz" =?> "foo<strong>bar</strong>baz" |