mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-25 09:47:06 +00:00
Muse reader: add secondary note support
This commit is contained in:
@@ -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) }
|
||||
|
||||
@@ -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]"
|
||||
, ""
|
||||
|
||||
Reference in New Issue
Block a user