mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-24 15:44:59 +08:00
Muse writer: escape horizontal rule only if at the beginning of the line
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -259,7 +259,9 @@ tests = [ testGroup "block elements"
|
||||
]
|
||||
]
|
||||
, "horizontal rule" =: horizontalRule =?> "----"
|
||||
, "escape horizontal rule" =: para (text "----") =?> "<verbatim>----</verbatim>"
|
||||
, "escape horizontal rule" =: para (text "----") =?> "<verbatim></verbatim>----"
|
||||
, "escape long horizontal rule" =: para (text "----------") =?> "<verbatim></verbatim>----------"
|
||||
, "don't escape horizontal inside paragraph" =: para (text "foo ---- bar") =?> "foo ---- bar"
|
||||
, "escape nonbreaking space" =: para (text "~~") =?> "<verbatim>~~</verbatim>"
|
||||
, testGroup "tables"
|
||||
[ "table without header" =:
|
||||
|
||||
Reference in New Issue
Block a user