aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2019-02-18 15:21:17 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2019-02-18 15:21:32 +0300
commit2c7c8a6f407a6299f7f7345ca9203fae6fb4bcde (patch)
treeeb734becf1ef9a64e49f4c2ece571c20f27665d0 /src/Text/Pandoc/Writers
parent073db7ac1f79437468702073bfbd97166b48753b (diff)
downloadpandoc-2c7c8a6f407a6299f7f7345ca9203fae6fb4bcde.tar.gz
Muse writer: escape secondary notes
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/Muse.hs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs
index c09545e85..2ceeaab37 100644
--- a/src/Text/Pandoc/Writers/Muse.hs
+++ b/src/Text/Pandoc/Writers/Muse.hs
@@ -377,10 +377,11 @@ startsWithMarker f (x:xs) =
startsWithDot _ = False
startsWithMarker _ [] = False
-containsFootnotes :: String -> Bool
-containsFootnotes = p
- where p ('[':xs) = q xs || p xs
- p (_:xs) = p xs
+containsNotes :: Char -> Char -> String -> Bool
+containsNotes left right = p
+ where p (left':xs)
+ | left' == left = q xs || p xs
+ | otherwise = p xs
p "" = False
q (x:xs)
| x `elem` ("123456789"::String) = r xs || p xs
@@ -388,8 +389,9 @@ containsFootnotes = p
q [] = False
r ('0':xs) = r xs || p xs
r xs = s xs || q xs || p xs
- s (']':_) = True
- s (_:xs) = p xs
+ s (right':xs)
+ | right' == right = True
+ | otherwise = p xs
s [] = False
-- | Return True if string should be escaped with <verbatim> tags
@@ -404,7 +406,8 @@ shouldEscapeString s = do
"~~" `isInfixOf` s ||
"[[" `isInfixOf` s ||
("]" `isInfixOf` s && insideLink) ||
- containsFootnotes s
+ containsNotes '[' ']' s ||
+ containsNotes '{' '}' s
-- | Escape special characters for Muse if needed.
conditionalEscapeString :: PandocMonad m