diff options
-rw-r--r-- | src/Text/Pandoc/Readers/Muse.hs | 16 | ||||
-rw-r--r-- | test/Tests/Readers/Muse.hs | 17 |
2 files changed, 28 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs index ba476f7d7..012eb017d 100644 --- a/src/Text/Pandoc/Readers/Muse.hs +++ b/src/Text/Pandoc/Readers/Muse.hs @@ -481,11 +481,17 @@ paraUntil end = do guard $ not inPara first (fmap B.para) <$> paraContentsUntil end -noteMarker :: PandocMonad m => MuseParser m String -noteMarker = try $ (:) - <$ char '[' +noteMarker' :: PandocMonad m + => Char + -> Char + -> MuseParser m String +noteMarker' l r = try $ (\x y -> l:x:y ++ [r]) + <$ char l <*> oneOf "123456789" - <*> manyTill digit (char ']') + <*> manyTill digit (char r) + +noteMarker :: PandocMonad m => MuseParser m String +noteMarker = noteMarker' '[' ']' <|> noteMarker' '{' '}' addNote :: PandocMonad m => String @@ -797,7 +803,7 @@ footnote = try $ do return $ do notes <- asksF museNotes case M.lookup ref notes of - Nothing -> return $ B.str $ "[" ++ ref ++ "]" + Nothing -> return $ B.str $ ref Just (_pos, contents) -> do st <- askF let contents' = runF contents st { museNotes = M.delete ref (museNotes st) } diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs index 8fbe6a955..e864cb46e 100644 --- a/test/Tests/Readers/Muse.hs +++ b/test/Tests/Readers/Muse.hs @@ -784,6 +784,23 @@ tests = para (text "Here is a footnote" <> note (para "Footnote contents") <> str ".") + , "Simple secondary footnote" =: + T.unlines [ "Here is a secondary note{1}." + , "" + , "{1} Secondary note contents" + ] =?> + para (text "Here is a secondary note" <> + note (para "Secondary note contents") <> + str ".") + , "Missing footnote" =: "Foo[1]" =?> para "Foo[1]" + , "Missing secondary note" =: "Foo{1}" =?> para "Foo{1}" + , "Wrong note type" =: + T.unlines [ "Here is a secondary note{1}" + , "" + , "Footnote contents[1]" + ] =?> + para "Here is a secondary note{1}" <> + para "Footnote contents[1]" , "Recursive footnote" =: T.unlines [ "Start recursion here[1]" , "" |