git.iko.soy/typeable/pandoc
on master help sign in
Muse writer: escape strings starting with space
17767bdAlexander Krotov
src/Text/Pandoc/Writers/Muse.hs+5−1
@@ -400,6 +400,10 @@ isHorizontalRule s =
400 ((length xs) >= 4) && null ys
400 ((length xs) >= 4) && null ys
401 where (xs, ys) = span (== '-') s
401 where (xs, ys) = span (== '-') s
402
402
403+startsWithSpace :: String -> Bool
404+startsWithSpace (x:_) = isSpace x
405+startsWithSpace [] = False
406+
403fixOrEscape :: Bool -> Inline -> Bool
407fixOrEscape :: Bool -> Inline -> Bool
404fixOrEscape sp (Str "-") = sp
408fixOrEscape sp (Str "-") = sp
405fixOrEscape sp (Str ";") = not sp
409fixOrEscape sp (Str ";") = not sp
@@ -407,7 +411,7 @@ fixOrEscape _ (Str ">") = True
407fixOrEscape sp (Str s) = (sp && (startsWithMarker isDigit s ||
411fixOrEscape sp (Str s) = (sp && (startsWithMarker isDigit s ||
408 startsWithMarker isAsciiLower s ||
412 startsWithMarker isAsciiLower s ||
409 startsWithMarker isAsciiUpper s))
413 startsWithMarker isAsciiUpper s))
410− || isHorizontalRule s
414+ || isHorizontalRule s || startsWithSpace s
411fixOrEscape _ Space = True
415fixOrEscape _ Space = True
412fixOrEscape _ SoftBreak = True
416fixOrEscape _ SoftBreak = True
413fixOrEscape _ _ = False
417fixOrEscape _ _ = False
test/Tests/Writers/Muse.hs+9
@@ -112,6 +112,15 @@ tests = [ testGroup "block elements"
112 , " <verbatim></verbatim> :: second description"
112 , " <verbatim></verbatim> :: second description"
113 , " <verbatim></verbatim> :: third description"
113 , " <verbatim></verbatim> :: third description"
114 ]
114 ]
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+ ]
115 ]
124 ]
116 -- Test that lists of the same type and style are separated with two blanklines
125 -- Test that lists of the same type and style are separated with two blanklines
117 , testGroup "sequential lists"
126 , testGroup "sequential lists"