From e27ded9c385958295b28ed88cd6e6888a1c541b2 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sat, 1 Sep 2018 15:51:39 +0300 Subject: Muse writer: separate "shouldEscapeString" function --- src/Text/Pandoc/Writers/Muse.hs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs index 123ca94e4..7f3b64ea7 100644 --- a/src/Text/Pandoc/Writers/Muse.hs +++ b/src/Text/Pandoc/Writers/Muse.hs @@ -321,14 +321,19 @@ containsFootnotes = p s (_:xs) = p xs s [] = False +-- | Return True if string should be escaped with tags +shouldEscapeString :: Bool -> String -> Bool +shouldEscapeString isInsideLinkDescription s = + any (`elem` ("#*<=|" :: String)) s || + "::" `isInfixOf` s || + "~~" `isInfixOf` s || + "[[" `isInfixOf` s || + ("]" `isInfixOf` s && isInsideLinkDescription) || + containsFootnotes s + conditionalEscapeString :: Bool -> String -> String conditionalEscapeString isInsideLinkDescription s = - if any (`elem` ("#*<=|" :: String)) s || - "::" `isInfixOf` s || - "~~" `isInfixOf` s || - "[[" `isInfixOf` s || - ("]" `isInfixOf` s && isInsideLinkDescription) || - containsFootnotes s + if shouldEscapeString isInsideLinkDescription s then escapeString s else s -- cgit v1.2.3