@@ -498,10 +498,21 @@ paraUntil end = do
498498 guard $ not $ museInPara state
499499 first (fmap B. para) <$> paraContentsUntil end
500500
501- noteMarker :: PandocMonad m => MuseParser m String
502- noteMarker = try $ do
503- char ' ['
504- (:) <$> oneOf " 123456789" <*> manyTill digit (char ' ]' )
501+ noteBrackets :: NoteType -> (Char , Char )
502+ noteBrackets nt =
503+ case nt of
504+ Endnote -> (' {' , ' }' )
505+ _ -> (' [' , ' ]' )
506+
507+ noteMarker :: PandocMonad m => NoteType -> MuseParser m (NoteType , String )
508+ noteMarker nt = try $ do
509+ char l
510+ m <- (:) <$> oneOf " 123456789" <*> manyTill digit (char r)
511+ return (nt, [l] ++ m ++ [r])
512+ where (l, r) = noteBrackets nt
513+
514+ anyNoteMarker :: PandocMonad m => MuseParser m (NoteType , String )
515+ anyNoteMarker = noteMarker Footnote <|> noteMarker Endnote
505516
506517-- Amusewiki version of note
507518-- Parsing is similar to list item, except that note marker is used instead of list marker
@@ -510,7 +521,7 @@ amuseNoteBlockUntil :: PandocMonad m
510521 -> MuseParser m (F Blocks , a )
511522amuseNoteBlockUntil end = try $ do
512523 guardEnabled Ext_amuse
513- ref <- noteMarker <* spaceChar
524+ (_, ref) <- anyNoteMarker <* spaceChar
514525 pos <- getPosition
515526 updateState (\ st -> st { museInPara = False })
516527 (content, e) <- listItemContentsUntil (sourceColumn pos - 1 ) (fail " x" ) end
@@ -526,7 +537,7 @@ emacsNoteBlock :: PandocMonad m => MuseParser m (F Blocks)
526537emacsNoteBlock = try $ do
527538 guardDisabled Ext_amuse
528539 pos <- getPosition
529- ref <- noteMarker <* skipSpaces
540+ (_, ref) <- anyNoteMarker <* skipSpaces
530541 content <- mconcat <$> blocksTillNote
531542 oldnotes <- museNotes <$> getState
532543 when (M. member ref oldnotes)
@@ -535,7 +546,7 @@ emacsNoteBlock = try $ do
535546 return mempty
536547 where
537548 blocksTillNote =
538- many1Till parseBlock (eof <|> () <$ lookAhead noteMarker )
549+ many1Till parseBlock (eof <|> () <$ lookAhead anyNoteMarker )
539550
540551--
541552-- Verse markup
@@ -814,15 +825,15 @@ footnote :: PandocMonad m => MuseParser m (F Inlines)
814825footnote = try $ do
815826 inLink <- museInLink <$> getState
816827 guard $ not inLink
817- ref <- noteMarker
828+ (notetype, ref) <- anyNoteMarker
818829 return $ do
819830 notes <- asksF museNotes
820831 case M. lookup ref notes of
821- Nothing -> return $ B. str $ " [ " ++ ref ++ " ] "
832+ Nothing -> return $ B. str ref
822833 Just (_pos, contents) -> do
823834 st <- askF
824835 let contents' = runF contents st { museNotes = M. delete ref (museNotes st) }
825- return $ B. note contents'
836+ return $ B. singleton $ Note notetype $ B. toList contents'
826837
827838whitespace :: PandocMonad m => MuseParser m (F Inlines )
828839whitespace = try $ do
0 commit comments