aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Writers/Muse.hs17
-rw-r--r--test/Tests/Writers/Muse.hs1
2 files changed, 11 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
diff --git a/test/Tests/Writers/Muse.hs b/test/Tests/Writers/Muse.hs
index c2439b1a2..834422a59 100644
--- a/test/Tests/Writers/Muse.hs
+++ b/test/Tests/Writers/Muse.hs
@@ -428,6 +428,7 @@ tests = [ testGroup "block elements"
[ testGroup "string"
[ "string" =: str "foo" =?> "foo"
, "escape footnote" =: str "[1]" =?> "<verbatim>[1]</verbatim>"
+ , "escape secondary note" =: str "{1}" =?> "<verbatim>{1}</verbatim>"
, "do not escape brackets" =: str "[12ab]" =?> "[12ab]"
, "escape verbatim close tag" =: str "foo</verbatim>bar"
=?> "<verbatim>foo<</verbatim><verbatim>/verbatim>bar</verbatim>"