git.iko.soy/typeable/pandoc
on master help sign in
Muse writer: escape strings starting with space
commit17767bd29d54883364d4d9bdee417973ac0a10ac authorAlexander Krotov <ilabdsf@gmail.com> dateSun 15 Apr 2018, 16:07 (9 years ago) parent9cc2bf0
2 files changed+14−1
src/Text/Pandoc/Writers/Muse.hs+5−1 test/Tests/Writers/Muse.hs+9
src/Text/Pandoc/Writers/Muse.hs+5−1
@@ -400,6 +400,10 @@ isHorizontalRule s =
400400 ((length xs) >= 4) && null ys
401401 where (xs, ys) = span (== '-') s
402402
403+startsWithSpace :: String -> Bool
404+startsWithSpace (x:_) = isSpace x
405+startsWithSpace [] = False
406+
403407fixOrEscape :: Bool -> Inline -> Bool
404408fixOrEscape sp (Str "-") = sp
405409fixOrEscape sp (Str ";") = not sp
@@ -407,7 +411,7 @@ fixOrEscape _ (Str ">") = True
407411fixOrEscape sp (Str s) = (sp && (startsWithMarker isDigit s ||
408412 startsWithMarker isAsciiLower s ||
409413 startsWithMarker isAsciiUpper s))
410− || isHorizontalRule s
414+ || isHorizontalRule s || startsWithSpace s
411415fixOrEscape _ Space = True
412416fixOrEscape _ SoftBreak = True
413417fixOrEscape _ _ = False
test/Tests/Writers/Muse.hs+9
@@ -112,6 +112,15 @@ tests = [ testGroup "block elements"
112112 , " <verbatim></verbatim> :: second description"
113113 , " <verbatim></verbatim> :: third description"
114114 ]
115+ , "definition list terms starting with space" =:
116+ definitionList [ (text "first definition", [plain $ text "first description"])
117+ , (space <> str "foo", [plain $ text "second description"])
118+ , (str " > bar", [plain $ text "third description"])
119+ ]
120+ =?> unlines [ " first definition :: first description"
121+ , " <verbatim></verbatim> foo :: second description"
122+ , " <verbatim></verbatim> > bar :: third description"
123+ ]
115124 ]
116125 -- Test that lists of the same type and style are separated with two blanklines
117126 , testGroup "sequential lists"