@@ -335,21 +335,31 @@ para = do
335
335
endOfPara = try $ blankline >> skipMany1 blankline
336
336
newBlockElement = try $ blankline >> void blockElements
337
337
338
- noteMarker :: PandocMonad m => MuseParser m String
339
- noteMarker = try $ do
340
- char ' ['
338
+ noteBrackets :: NoteType -> (Char , Char )
339
+ noteBrackets nt =
340
+ case nt of
341
+ EndNote -> (' {' , ' }' )
342
+ _ -> (' [' , ' ]' )
343
+
344
+ noteMarker :: PandocMonad m => NoteType -> MuseParser m (NoteType , String )
345
+ noteMarker nt = try $ do
346
+ char l
341
347
first <- oneOf " 123456789"
342
- rest <- manyTill digit (char ' ]' )
343
- return $ first: rest
348
+ rest <- manyTill digit (char r)
349
+ return (nt, [l] ++ (first: rest) ++ [r])
350
+ where (l, r) = noteBrackets nt
351
+
352
+ anyNoteMarker :: PandocMonad m => MuseParser m (NoteType , String )
353
+ anyNoteMarker = noteMarker FootNote <|> noteMarker EndNote
344
354
345
355
-- Amusewiki version of note
346
356
-- Parsing is similar to list item, except that note marker is used instead of list marker
347
357
amuseNoteBlock :: PandocMonad m => MuseParser m (F Blocks )
348
358
amuseNoteBlock = try $ do
349
359
guardEnabled Ext_amuse
350
360
pos <- getPosition
351
- ref <- noteMarker <* spaceChar
352
- content <- listItemContents $ 3 + length ref
361
+ (_, ref) <- anyNoteMarker <* spaceChar
362
+ content <- listItemContents $ 1 + length ref
353
363
oldnotes <- stateNotes' <$> getState
354
364
case M. lookup ref oldnotes of
355
365
Just _ -> logMessage $ DuplicateNoteReference ref pos
@@ -363,7 +373,7 @@ emacsNoteBlock :: PandocMonad m => MuseParser m (F Blocks)
363
373
emacsNoteBlock = try $ do
364
374
guardDisabled Ext_amuse
365
375
pos <- getPosition
366
- ref <- noteMarker <* skipSpaces
376
+ (_, ref) <- anyNoteMarker <* skipSpaces
367
377
content <- mconcat <$> blocksTillNote
368
378
oldnotes <- stateNotes' <$> getState
369
379
case M. lookup ref oldnotes of
@@ -373,7 +383,7 @@ emacsNoteBlock = try $ do
373
383
return mempty
374
384
where
375
385
blocksTillNote =
376
- many1Till block (eof <|> () <$ lookAhead noteMarker )
386
+ many1Till block (eof <|> () <$ lookAhead anyNoteMarker )
377
387
378
388
--
379
389
-- Verse markup
@@ -647,15 +657,15 @@ anchor = try $ do
647
657
648
658
footnote :: PandocMonad m => MuseParser m (F Inlines )
649
659
footnote = try $ do
650
- ref <- noteMarker
660
+ (notetype, ref) <- anyNoteMarker
651
661
return $ do
652
662
notes <- asksF stateNotes'
653
663
case M. lookup ref notes of
654
- Nothing -> return $ B. str $ " [ " ++ ref ++ " ] "
664
+ Nothing -> return $ B. str ref
655
665
Just (_pos, contents) -> do
656
666
st <- askF
657
667
let contents' = runF contents st { stateNotes' = M. empty }
658
- return $ B. note contents'
668
+ return $ B. singleton $ Note notetype $ B. toList contents'
659
669
660
670
whitespace :: PandocMonad m => MuseParser m (F Inlines )
661
671
whitespace = fmap return (lb <|> regsp)
0 commit comments