aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2018-04-15 16:07:43 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2018-04-15 16:28:45 +0300
commit17767bd29d54883364d4d9bdee417973ac0a10ac (patch)
treef60e995d0df021467b24e7e7cef5b33b6b6c2348
parent9cc2bf0295a66182223c9ec421a4755d1acebeb1 (diff)
downloadpandoc-17767bd29d54883364d4d9bdee417973ac0a10ac.tar.gz
Muse writer: escape strings starting with space
-rw-r--r--src/Text/Pandoc/Writers/Muse.hs6
-rw-r--r--test/Tests/Writers/Muse.hs9
2 files changed, 14 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs
index 127a4f149..4e7ce377a 100644
--- a/src/Text/Pandoc/Writers/Muse.hs
+++ b/src/Text/Pandoc/Writers/Muse.hs
@@ -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
diff --git a/test/Tests/Writers/Muse.hs b/test/Tests/Writers/Muse.hs
index 41c846b1b..44fdd5b7e 100644
--- a/test/Tests/Writers/Muse.hs
+++ b/test/Tests/Writers/Muse.hs
@@ -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"