Muse writer: escape "-" to avoid creating bullet lists

This commit is contained in:
Alexander Krotov 2018-03-07 15:19:36 +03:00
parent b6182afcfe
commit 1b1b6f02d5
3 changed files with 12 additions and 2 deletions

View file

@ -287,7 +287,8 @@ conditionalEscapeString s =
if any (`elem` ("#*<=>[]|" :: String)) s ||
"::" `isInfixOf` s ||
"----" `isInfixOf` s ||
"~~" `isInfixOf` s
"~~" `isInfixOf` s ||
"-" == s
then escapeString s
else s

View file

@ -301,6 +301,15 @@ tests = [ testGroup "block elements"
-- We don't want colons to be escaped if they can't be confused
-- with definition list item markers.
, "do not escape colon" =: str ":" =?> ":"
, "escape - to avoid accidental unordered lists" =: text " - foo" =?> " <verbatim>-</verbatim> foo"
, "escape - inside a list to avoid accidental nested unordered lists" =:
bulletList [ (para $ text "foo") <>
(para $ text "- bar")
] =?>
unlines [ " - foo"
, ""
, " <verbatim>-</verbatim> bar"
]
]
, testGroup "emphasis"
[ "emph" =: emph (text "foo") =?> "<em>foo</em>"

View file

@ -594,7 +594,7 @@ Bang: !
Plus: +
Minus: -
Minus: <verbatim>-</verbatim>
----