git.iko.soy/typeable/pandoc
on master help sign in
Muse writer: check for whitespace in the beginning and end of Str's
165a610Alexander Krotov
src/Text/Pandoc/Writers/Muse.hs+2
@@ -415,11 +415,13 @@ fixNotes (x:xs) = x : fixNotes xs
415startsWithSpace :: [Inline] -> Bool
415startsWithSpace :: [Inline] -> Bool
416startsWithSpace (Space:_) = True
416startsWithSpace (Space:_) = True
417startsWithSpace (SoftBreak:_) = True
417startsWithSpace (SoftBreak:_) = True
418+startsWithSpace (Str s:_) = stringStartsWithSpace s
418startsWithSpace _ = False
419startsWithSpace _ = False
419
420
420endsWithSpace :: [Inline] -> Bool
421endsWithSpace :: [Inline] -> Bool
421endsWithSpace [Space] = True
422endsWithSpace [Space] = True
422endsWithSpace [SoftBreak] = True
423endsWithSpace [SoftBreak] = True
424+endsWithSpace [Str s] = stringStartsWithSpace $ reverse s
423endsWithSpace (_:xs) = endsWithSpace xs
425endsWithSpace (_:xs) = endsWithSpace xs
424endsWithSpace [] = False
426endsWithSpace [] = False
425
427
test/Tests/Writers/Muse.hs+3
@@ -382,6 +382,9 @@ tests = [ testGroup "block elements"
382 , "strong empty string" =: strong (str "") =?> "<strong></strong>"
382 , "strong empty string" =: strong (str "") =?> "<strong></strong>"
383 , "strong emphasized empty string" =: strong (emph (str "")) =?> "**<em></em>**"
383 , "strong emphasized empty string" =: strong (emph (str "")) =?> "**<em></em>**"
384 , "emphasized strong empty string" =: emph (strong (str "")) =?> "*<strong></strong>*"
384 , "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>"
385 , "emphasized space between empty strings" =: emph (str "" <> space <> str "") =?> "<em> </em>"
388 , "emphasized space between empty strings" =: emph (str "" <> space <> str "") =?> "<em> </em>"
386 , "strong" =: strong (text "foo") =?> "**foo**"
389 , "strong" =: strong (text "foo") =?> "**foo**"
387 , "strong inside word" =: text "foo" <> strong (text "bar") <> text "baz" =?> "foo<strong>bar</strong>baz"
390 , "strong inside word" =: text "foo" <> strong (text "bar") <> text "baz" =?> "foo<strong>bar</strong>baz"