Only parse footnote definitions if they target a reference that exists.

This commit is contained in:
Tom Alexander 2023-10-29 21:44:15 -04:00
parent afe62de2b6
commit 2e7cfd5637
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 10 additions and 0 deletions

View File

@ -99,6 +99,16 @@ pub(crate) async fn register_footnote_definition<'orig, 'parse>(
label: &'parse str,
definition: &'orig Vec<Element<'parse>>,
) -> Result<(), CustomError> {
let has_existing: bool = {
let mut registry = registry.lock().unwrap();
registry
.footnote_ids
.iter_mut()
.any(|(id, _definition)| *id == Some(label))
};
if !has_existing {
return Ok(());
}
let contents = convert_definition_contents(registry.clone(), definition).await?;
let mut registry = registry.lock().unwrap();
if let Some((_existing_id, existing_definition)) = registry