diff options
author | Alexander Krotov <ilabdsf@gmail.com> | 2018-09-01 15:51:39 +0300 |
---|---|---|
committer | Alexander Krotov <ilabdsf@gmail.com> | 2018-09-01 15:51:39 +0300 |
commit | e27ded9c385958295b28ed88cd6e6888a1c541b2 (patch) | |
tree | 04abc22877289730f146f8fb5c5defdced57dd41 | |
parent | 3ddb7c9d3e337bf692c6328ca6466f3b1930e6c3 (diff) | |
download | pandoc-e27ded9c385958295b28ed88cd6e6888a1c541b2.tar.gz |
Muse writer: separate "shouldEscapeString" function
-rw-r--r-- | src/Text/Pandoc/Writers/Muse.hs | 17 |
1 files changed, 11 insertions, 6 deletions
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 <verbatim> 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 |