diff options
-rw-r--r-- | src/Text/Pandoc/Writers/Muse.hs | 9 | ||||
-rw-r--r-- | test/Tests/Writers/Muse.hs | 10 |
2 files changed, 16 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs index 413b71659..262d4fb50 100644 --- a/src/Text/Pandoc/Writers/Muse.hs +++ b/src/Text/Pandoc/Writers/Muse.hs @@ -437,12 +437,15 @@ stringStartsWithSpace [] = False fixOrEscape :: Bool -> Inline -> Bool fixOrEscape sp (Str "-") = sp -fixOrEscape sp (Str ";") = not sp -fixOrEscape _ (Str ">") = True +fixOrEscape sp (Str s@('-':x:_)) = (sp && isSpace x) || isHorizontalRule s +fixOrEscape sp (Str (";")) = not sp +fixOrEscape sp (Str (';':x:_)) = not sp && isSpace x +fixOrEscape _ (Str (">")) = True +fixOrEscape _ (Str ('>':x:_)) = isSpace x fixOrEscape sp (Str s) = (sp && (startsWithMarker isDigit s || startsWithMarker isAsciiLower s || startsWithMarker isAsciiUpper s)) - || isHorizontalRule s || stringStartsWithSpace s + || stringStartsWithSpace s fixOrEscape _ Space = True fixOrEscape _ SoftBreak = True fixOrEscape _ _ = False diff --git a/test/Tests/Writers/Muse.hs b/test/Tests/Writers/Muse.hs index 7821f4e96..a8ccd6d87 100644 --- a/test/Tests/Writers/Muse.hs +++ b/test/Tests/Writers/Muse.hs @@ -283,6 +283,7 @@ tests = [ testGroup "block elements" , "don't escape horizontal inside paragraph" =: para (text "foo ---- bar") =?> "foo ---- bar" , "escape nonbreaking space" =: para (text "~~") =?> "<verbatim>~~</verbatim>" , "escape > in the beginning of line" =: para (text "> foo bar") =?> "<verbatim></verbatim>> foo bar" + , "escape string with > and space in the beginning of line" =: para (str "> foo bar") =?> "<verbatim></verbatim>> foo bar" , testGroup "tables" [ "table without header" =: let rows = [[para $ text "Para 1.1", para $ text "Para 1.2"] @@ -348,6 +349,14 @@ tests = [ testGroup "block elements" , "" , " <verbatim></verbatim>- bar" ] + , "escape strings starting with - inside a list" =: + bulletList [ para (str "foo") <> + para (str "- bar") + ] =?> + unlines [ " - foo" + , "" + , " <verbatim></verbatim>- bar" + ] , "escape - inside a note" =: note (para (text "- foo")) =?> unlines [ "[1]" @@ -355,6 +364,7 @@ tests = [ testGroup "block elements" , "[1] <verbatim></verbatim>- foo" ] , "escape ; to avoid accidental comments" =: text "; foo" =?> "<verbatim></verbatim>; foo" + , "escape strings starting with ; and space" =: str "; foo" =?> "<verbatim></verbatim>; foo" , "escape ; after softbreak" =: text "foo" <> softbreak <> text "; bar" =?> "foo\n<verbatim></verbatim>; bar" , "escape ; after linebreak" =: text "foo" <> linebreak <> text "; bar" =?> "foo<br>\n<verbatim></verbatim>; bar" , "do not escape ; inside paragraph" =: text "foo ; bar" =?> "foo ; bar" |