aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2018-04-05 19:48:39 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2018-04-05 19:49:09 +0300
commit87dda2109d01098dcf41c01559d3e91e2627cd10 (patch)
treec4214017ce275b1de10e894045010b1b28fb6398 /src/Text/Pandoc/Writers
parent16104881b34596b39e41d4fd47f3e3af68e575ac (diff)
downloadpandoc-87dda2109d01098dcf41c01559d3e91e2627cd10.tar.gz
Muse writer: escape horizontal rule only if at the beginning of the line
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/Muse.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs
index 4986aa8a6..e9cf6d433 100644
--- a/src/Text/Pandoc/Writers/Muse.hs
+++ b/src/Text/Pandoc/Writers/Muse.hs
@@ -325,7 +325,6 @@ conditionalEscapeString :: Bool -> String -> String
conditionalEscapeString isInsideLinkDescription s =
if any (`elem` ("#*<=>|" :: String)) s ||
"::" `isInfixOf` s ||
- "----" `isInfixOf` s ||
"~~" `isInfixOf` s ||
"[[" `isInfixOf` s ||
("]" `isInfixOf` s && isInsideLinkDescription) ||
@@ -395,12 +394,18 @@ urlEscapeBrackets (']':xs) = '%':'5':'D':urlEscapeBrackets xs
urlEscapeBrackets (x:xs) = x:urlEscapeBrackets xs
urlEscapeBrackets [] = []
+isHorizontalRule :: String -> Bool
+isHorizontalRule s =
+ ((length xs) >= 4) && null ys
+ where (xs, ys) = span (== '-') s
+
fixOrEscape :: Bool -> Inline -> Bool
fixOrEscape sp (Str "-") = sp
fixOrEscape sp (Str ";") = not sp
-fixOrEscape sp (Str s) = sp && (startsWithMarker isDigit s ||
+fixOrEscape sp (Str s) = (sp && (startsWithMarker isDigit s ||
startsWithMarker isAsciiLower s ||
- startsWithMarker isAsciiUpper s)
+ startsWithMarker isAsciiUpper s))
+ || isHorizontalRule s
fixOrEscape _ Space = True
fixOrEscape _ SoftBreak = True
fixOrEscape _ _ = False