HTML reader: give warnings and emit empty note...
when parsing `<a epub:type="noteref">` and the identifier doesn't correspond to anything in the note table. Previously we just silently skipped these cases. See #7884.
This commit is contained in:
parent
4864761ad8
commit
93b1dbfdac
1 changed files with 10 additions and 4 deletions
|
@ -107,12 +107,18 @@ stripPrefix x = x
|
|||
replaceNotes :: PandocMonad m => [Block] -> TagParser m [Block]
|
||||
replaceNotes bs = do
|
||||
st <- getState
|
||||
return $ walk (replaceNotes' (noteTable st)) bs
|
||||
walkM (replaceNotes' (noteTable st)) bs
|
||||
|
||||
replaceNotes' :: [(Text, Blocks)] -> Inline -> Inline
|
||||
replaceNotes' :: PandocMonad m
|
||||
=> [(Text, Blocks)] -> Inline -> TagParser m Inline
|
||||
replaceNotes' noteTbl (RawInline (Format "noteref") ref) =
|
||||
maybe (Str "") (Note . B.toList) $ lookup ref noteTbl
|
||||
replaceNotes' _ x = x
|
||||
maybe warnNotFound (pure . Note . B.toList) $ lookup ref noteTbl
|
||||
where
|
||||
warnNotFound = do
|
||||
pos <- getPosition
|
||||
logMessage $ ReferenceNotFound ref pos
|
||||
pure (Note [])
|
||||
replaceNotes' _ x = pure x
|
||||
|
||||
setInChapter :: PandocMonad m => HTMLParser m s a -> HTMLParser m s a
|
||||
setInChapter = local (\s -> s {inChapter = True})
|
||||
|
|
Loading…
Add table
Reference in a new issue