mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-24 15:44:59 +08:00
Muse writer: escape strings starting with space
This commit is contained in:
@@ -400,6 +400,10 @@ isHorizontalRule s =
|
||||
((length xs) >= 4) && null ys
|
||||
where (xs, ys) = span (== '-') s
|
||||
|
||||
startsWithSpace :: String -> Bool
|
||||
startsWithSpace (x:_) = isSpace x
|
||||
startsWithSpace [] = False
|
||||
|
||||
fixOrEscape :: Bool -> Inline -> Bool
|
||||
fixOrEscape sp (Str "-") = sp
|
||||
fixOrEscape sp (Str ";") = not sp
|
||||
@@ -407,7 +411,7 @@ fixOrEscape _ (Str ">") = True
|
||||
fixOrEscape sp (Str s) = (sp && (startsWithMarker isDigit s ||
|
||||
startsWithMarker isAsciiLower s ||
|
||||
startsWithMarker isAsciiUpper s))
|
||||
|| isHorizontalRule s
|
||||
|| isHorizontalRule s || startsWithSpace s
|
||||
fixOrEscape _ Space = True
|
||||
fixOrEscape _ SoftBreak = True
|
||||
fixOrEscape _ _ = False
|
||||
|
||||
@@ -112,6 +112,15 @@ tests = [ testGroup "block elements"
|
||||
, " <verbatim></verbatim> :: second description"
|
||||
, " <verbatim></verbatim> :: third description"
|
||||
]
|
||||
, "definition list terms starting with space" =:
|
||||
definitionList [ (text "first definition", [plain $ text "first description"])
|
||||
, (space <> str "foo", [plain $ text "second description"])
|
||||
, (str " > bar", [plain $ text "third description"])
|
||||
]
|
||||
=?> unlines [ " first definition :: first description"
|
||||
, " <verbatim></verbatim> foo :: second description"
|
||||
, " <verbatim></verbatim> > bar :: third description"
|
||||
]
|
||||
]
|
||||
-- Test that lists of the same type and style are separated with two blanklines
|
||||
, testGroup "sequential lists"
|
||||
|
||||
Reference in New Issue
Block a user