git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: add secondary note support
commitc4814ea965704ffb3bc7cf5e918a2fc342d401b3 authorAlexander Krotov <ilabdsf@gmail.com> dateMon 18 Feb 2019, 15:09 (8 years ago) parent2c7c8a6
2 files changed+28−5
src/Text/Pandoc/Readers/Muse.hs+11−5 test/Tests/Readers/Muse.hs+17
src/Text/Pandoc/Readers/Muse.hs+11−5
@@ -481,11 +481,17 @@ paraUntil end = do
481481 guard $ not inPara
482482 first (fmap B.para) <$> paraContentsUntil end
483483
484−noteMarker :: PandocMonad m => MuseParser m String
485−noteMarker = try $ (:)
486− <$ char '['
484+noteMarker' :: PandocMonad m
485+ => Char
486+ -> Char
487+ -> MuseParser m String
488+noteMarker' l r = try $ (\x y -> l:x:y ++ [r])
489+ <$ char l
487490 <*> oneOf "123456789"
488− <*> manyTill digit (char ']')
491+ <*> manyTill digit (char r)
492+
493+noteMarker :: PandocMonad m => MuseParser m String
494+noteMarker = noteMarker' '[' ']' <|> noteMarker' '{' '}'
489495
490496addNote :: PandocMonad m
491497 => String
@@ -797,7 +803,7 @@ footnote = try $ do
797803 return $ do
798804 notes <- asksF museNotes
799805 case M.lookup ref notes of
800− Nothing -> return $ B.str $ "[" ++ ref ++ "]"
806+ Nothing -> return $ B.str $ ref
801807 Just (_pos, contents) -> do
802808 st <- askF
803809 let contents' = runF contents st { museNotes = M.delete ref (museNotes st) }
test/Tests/Readers/Muse.hs+17
@@ -784,6 +784,23 @@ tests =
784784 para (text "Here is a footnote" <>
785785 note (para "Footnote contents") <>
786786 str ".")
787+ , "Simple secondary footnote" =:
788+ T.unlines [ "Here is a secondary note{1}."
789+ , ""
790+ , "{1} Secondary note contents"
791+ ] =?>
792+ para (text "Here is a secondary note" <>
793+ note (para "Secondary note contents") <>
794+ str ".")
795+ , "Missing footnote" =: "Foo[1]" =?> para "Foo[1]"
796+ , "Missing secondary note" =: "Foo{1}" =?> para "Foo{1}"
797+ , "Wrong note type" =:
798+ T.unlines [ "Here is a secondary note{1}"
799+ , ""
800+ , "Footnote contents[1]"
801+ ] =?>
802+ para "Here is a secondary note{1}" <>
803+ para "Footnote contents[1]"
787804 , "Recursive footnote" =:
788805 T.unlines [ "Start recursion here[1]"
789806 , ""