From 782ab73aa350ca323b0b7786770e37d1a932f9a8 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Tue, 10 Apr 2018 23:38:30 +0300 Subject: Muse writer: escape > less often > should be escaped only when it can start verse, i.e., at the beginning of the line. --- src/Text/Pandoc/Writers/Muse.hs | 3 ++- test/Tests/Writers/Muse.hs | 1 + test/writer.muse | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs index 0cfc2b8c4..127a4f149 100644 --- a/src/Text/Pandoc/Writers/Muse.hs +++ b/src/Text/Pandoc/Writers/Muse.hs @@ -324,7 +324,7 @@ containsFootnotes st = conditionalEscapeString :: Bool -> String -> String conditionalEscapeString isInsideLinkDescription s = - if any (`elem` ("#*<=>|" :: String)) s || + if any (`elem` ("#*<=|" :: String)) s || "::" `isInfixOf` s || "~~" `isInfixOf` s || "[[" `isInfixOf` s || @@ -403,6 +403,7 @@ isHorizontalRule s = fixOrEscape :: Bool -> Inline -> Bool fixOrEscape sp (Str "-") = sp fixOrEscape sp (Str ";") = not sp +fixOrEscape _ (Str ">") = True fixOrEscape sp (Str s) = (sp && (startsWithMarker isDigit s || startsWithMarker isAsciiLower s || startsWithMarker isAsciiUpper s)) diff --git a/test/Tests/Writers/Muse.hs b/test/Tests/Writers/Muse.hs index 5d84150e1..41c846b1b 100644 --- a/test/Tests/Writers/Muse.hs +++ b/test/Tests/Writers/Muse.hs @@ -264,6 +264,7 @@ tests = [ testGroup "block elements" , "escape long horizontal rule" =: para (text "----------") =?> "----------" , "don't escape horizontal inside paragraph" =: para (text "foo ---- bar") =?> "foo ---- bar" , "escape nonbreaking space" =: para (text "~~") =?> "~~" + , "escape > in the beginning of line" =: para (text "> foo bar") =?> "> foo bar" , testGroup "tables" [ "table without header" =: let rows = [[para $ text "Para 1.1", para $ text "Para 1.2"] diff --git a/test/writer.muse b/test/writer.muse index 83a53a1ab..9492a5517 100644 --- a/test/writer.muse +++ b/test/writer.muse @@ -79,7 +79,7 @@ nested -This should not be a block quote: 2 > 1. +This should not be a block quote: 2 > 1. And a following paragraph. @@ -562,7 +562,7 @@ This & that. 4 < 5. -6 > 5. +6 > 5. Backslash: \ @@ -584,7 +584,7 @@ Left paren: ( Right paren: ) -Greater-than: > +Greater-than: > Hash: # -- cgit v1.2.3