git.iko.soy/typeable/pandoc
on master help sign in
Muse writer: escape secondary notes
commit2c7c8a6f407a6299f7f7345ca9203fae6fb4bcde authorAlexander Krotov <ilabdsf@gmail.com> dateMon 18 Feb 2019, 15:21 (8 years ago) parent073db7a
2 files changed+11−7
src/Text/Pandoc/Writers/Muse.hs+10−7 test/Tests/Writers/Muse.hs+1
src/Text/Pandoc/Writers/Muse.hs+10−7
@@ -377,10 +377,11 @@ startsWithMarker f (x:xs) =
377377 startsWithDot _ = False
378378startsWithMarker _ [] = False
379379
380−containsFootnotes :: String -> Bool
381−containsFootnotes = p
382− where p ('[':xs) = q xs || p xs
383− p (_:xs) = p xs
380+containsNotes :: Char -> Char -> String -> Bool
381+containsNotes left right = p
382+ where p (left':xs)
383+ | left' == left = q xs || p xs
384+ | otherwise = p xs
384385 p "" = False
385386 q (x:xs)
386387 | x `elem` ("123456789"::String) = r xs || p xs
@@ -388,8 +389,9 @@ containsFootnotes = p
388389 q [] = False
389390 r ('0':xs) = r xs || p xs
390391 r xs = s xs || q xs || p xs
391− s (']':_) = True
392− s (_:xs) = p xs
392+ s (right':xs)
393+ | right' == right = True
394+ | otherwise = p xs
393395 s [] = False
394396
395397-- | Return True if string should be escaped with <verbatim> tags
@@ -404,7 +406,8 @@ shouldEscapeString s = do
404406 "~~" `isInfixOf` s ||
405407 "[[" `isInfixOf` s ||
406408 ("]" `isInfixOf` s && insideLink) ||
407− containsFootnotes s
409+ containsNotes '[' ']' s ||
410+ containsNotes '{' '}' s
408411
409412-- | Escape special characters for Muse if needed.
410413conditionalEscapeString :: PandocMonad m
test/Tests/Writers/Muse.hs+1
@@ -428,6 +428,7 @@ tests = [ testGroup "block elements"
428428 [ testGroup "string"
429429 [ "string" =: str "foo" =?> "foo"
430430 , "escape footnote" =: str "[1]" =?> "<verbatim>[1]</verbatim>"
431+ , "escape secondary note" =: str "{1}" =?> "<verbatim>{1}</verbatim>"
431432 , "do not escape brackets" =: str "[12ab]" =?> "[12ab]"
432433 , "escape verbatim close tag" =: str "foo</verbatim>bar"
433434 =?> "<verbatim>foo<</verbatim><verbatim>/verbatim>bar</verbatim>"