git.iko.soy/typeable/pandoc
on master help sign in
Muse writer: check for whitespace in the beginning and end of Str's
commit165a61095c08794d1639a683f1c6f1a82387c8d5 authorAlexander Krotov <ilabdsf@gmail.com> dateTue 11 Sep 2018, 11:49 (8 years ago) parentcb28cab
2 files changed+5
src/Text/Pandoc/Writers/Muse.hs+2 test/Tests/Writers/Muse.hs+3
src/Text/Pandoc/Writers/Muse.hs+2
@@ -415,11 +415,13 @@ fixNotes (x:xs) = x : fixNotes xs
415415startsWithSpace :: [Inline] -> Bool
416416startsWithSpace (Space:_) = True
417417startsWithSpace (SoftBreak:_) = True
418+startsWithSpace (Str s:_) = stringStartsWithSpace s
418419startsWithSpace _ = False
419420
420421endsWithSpace :: [Inline] -> Bool
421422endsWithSpace [Space] = True
422423endsWithSpace [SoftBreak] = True
424+endsWithSpace [Str s] = stringStartsWithSpace $ reverse s
423425endsWithSpace (_:xs) = endsWithSpace xs
424426endsWithSpace [] = False
425427
test/Tests/Writers/Muse.hs+3
@@ -382,6 +382,9 @@ tests = [ testGroup "block elements"
382382 , "strong empty string" =: strong (str "") =?> "<strong></strong>"
383383 , "strong emphasized empty string" =: strong (emph (str "")) =?> "**<em></em>**"
384384 , "emphasized strong empty string" =: emph (strong (str "")) =?> "*<strong></strong>*"
385+ , "emphasized string with space" =: emph (str " ") =?> "<em> </em>"
386+ , "emphasized string ending with space" =: emph (str "foo ") =?> "<em>foo </em>"
387+ , "emphasized string with tab" =: emph (str "\t") =?> "<em>\t</em>"
385388 , "emphasized space between empty strings" =: emph (str "" <> space <> str "") =?> "<em> </em>"
386389 , "strong" =: strong (text "foo") =?> "**foo**"
387390 , "strong inside word" =: text "foo" <> strong (text "bar") <> text "baz" =?> "foo<strong>bar</strong>baz"