From 7e42857ed8357bc5b5e9528d9fd09408f27ab4e1 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Wed, 22 Nov 2017 00:17:15 +0300 Subject: Muse writer: escape "----" to avoid accidental horizontal rules --- src/Text/Pandoc/Writers/Muse.hs | 10 ++++++---- test/Tests/Writers/Muse.hs | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs index c834e5883..8963c7ce4 100644 --- a/src/Text/Pandoc/Writers/Muse.hs +++ b/src/Text/Pandoc/Writers/Muse.hs @@ -284,10 +284,12 @@ escapeString s = -- | Escape special characters for Muse if needed. conditionalEscapeString :: String -> String -conditionalEscapeString s - | any (`elem` ("*<=>[]|" :: String)) s || - "::" `isInfixOf` s = escapeString s - | otherwise = s +conditionalEscapeString s = + if any (`elem` ("*<=>[]|" :: String)) s || + "::" `isInfixOf` s || + "----" `isInfixOf` s + then escapeString s + else s -- | Convert list of Pandoc inline elements to Muse. inlineListToMuse :: PandocMonad m diff --git a/test/Tests/Writers/Muse.hs b/test/Tests/Writers/Muse.hs index 7e95ae85e..a19f2f57e 100644 --- a/test/Tests/Writers/Muse.hs +++ b/test/Tests/Writers/Muse.hs @@ -236,6 +236,7 @@ tests = [ testGroup "block elements" ] ] , "horizontal rule" =: horizontalRule =?> "----" + , "escape horizontal rule" =: para (text "----") =?> "----" , testGroup "tables" [ "table without header" =: let rows = [[para $ text "Para 1.1", para $ text "Para 1.2"] -- cgit v1.2.3