@@ -496,10 +496,21 @@ paraUntil end = do
496496 guard $ not $ museInPara state
497497 first (fmap B. para) <$> paraContentsUntil end
498498
499- noteMarker :: PandocMonad m => MuseParser m String
500- noteMarker = try $ do
501- char ' ['
502- (:) <$> oneOf " 123456789" <*> manyTill digit (char ' ]' )
499+ noteBrackets :: NoteType -> (Char , Char )
500+ noteBrackets nt =
501+ case nt of
502+ Endnote -> (' {' , ' }' )
503+ _ -> (' [' , ' ]' )
504+
505+ noteMarker :: PandocMonad m => NoteType -> MuseParser m (NoteType , String )
506+ noteMarker nt = try $ do
507+ char l
508+ m <- (:) <$> oneOf " 123456789" <*> manyTill digit (char r)
509+ return (nt, [l] ++ m ++ [r])
510+ where (l, r) = noteBrackets nt
511+
512+ anyNoteMarker :: PandocMonad m => MuseParser m (NoteType , String )
513+ anyNoteMarker = noteMarker Footnote <|> noteMarker Endnote
503514
504515-- Amusewiki version of note
505516-- Parsing is similar to list item, except that note marker is used instead of list marker
@@ -508,7 +519,7 @@ amuseNoteBlockUntil :: PandocMonad m
508519 -> MuseParser m (F Blocks , a )
509520amuseNoteBlockUntil end = try $ do
510521 guardEnabled Ext_amuse
511- ref <- noteMarker <* spaceChar
522+ (_, ref) <- anyNoteMarker <* spaceChar
512523 pos <- getPosition
513524 updateState (\ st -> st { museInPara = False })
514525 (content, e) <- listItemContentsUntil (sourceColumn pos - 1 ) (fail " x" ) end
@@ -524,7 +535,7 @@ emacsNoteBlock :: PandocMonad m => MuseParser m (F Blocks)
524535emacsNoteBlock = try $ do
525536 guardDisabled Ext_amuse
526537 pos <- getPosition
527- ref <- noteMarker <* skipSpaces
538+ (_, ref) <- anyNoteMarker <* skipSpaces
528539 content <- mconcat <$> blocksTillNote
529540 oldnotes <- museNotes <$> getState
530541 when (M. member ref oldnotes)
@@ -533,7 +544,7 @@ emacsNoteBlock = try $ do
533544 return mempty
534545 where
535546 blocksTillNote =
536- many1Till parseBlock (eof <|> () <$ lookAhead noteMarker )
547+ many1Till parseBlock (eof <|> () <$ lookAhead anyNoteMarker )
537548
538549--
539550-- Verse markup
@@ -812,15 +823,15 @@ footnote :: PandocMonad m => MuseParser m (F Inlines)
812823footnote = try $ do
813824 inLink <- museInLink <$> getState
814825 guard $ not inLink
815- ref <- noteMarker
826+ (notetype, ref) <- anyNoteMarker
816827 return $ do
817828 notes <- asksF museNotes
818829 case M. lookup ref notes of
819- Nothing -> return $ B. str $ " [ " ++ ref ++ " ] "
830+ Nothing -> return $ B. str ref
820831 Just (_pos, contents) -> do
821832 st <- askF
822833 let contents' = runF contents st { museNotes = M. delete ref (museNotes st) }
823- return $ B. note contents'
834+ return $ B. singleton $ Note notetype $ B. toList contents'
824835
825836whitespace :: PandocMonad m => MuseParser m (F Inlines )
826837whitespace = try $ do
0 commit comments