aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2018-09-01 15:51:39 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2018-09-01 15:51:39 +0300
commite27ded9c385958295b28ed88cd6e6888a1c541b2 (patch)
tree04abc22877289730f146f8fb5c5defdced57dd41 /src/Text/Pandoc/Writers
parent3ddb7c9d3e337bf692c6328ca6466f3b1930e6c3 (diff)
downloadpandoc-e27ded9c385958295b28ed88cd6e6888a1c541b2.tar.gz
Muse writer: separate "shouldEscapeString" function
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/Muse.hs17
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