Order the footnotes based on when they start processing rather than when they finish.
This has the benefit of making the output order make sense when footnote definitions reference footnote references but I mostly did it to match the behavior of upstream org-mode.
This commit is contained in:
parent
0ae492f8d3
commit
ff03140007
@ -82,13 +82,21 @@ pub(crate) async fn get_footnote_reference_id<'orig, 'parse>(
|
||||
}
|
||||
Ok(existing_id)
|
||||
} else {
|
||||
let contents = convert_reference_contents(registry.clone(), definition).await?;
|
||||
let pos = {
|
||||
let existing_id = {
|
||||
let mut registry = registry.lock().unwrap();
|
||||
registry.footnote_ids.push((label, contents));
|
||||
registry.footnote_ids.push((label, Vec::new()));
|
||||
registry.footnote_ids.len() - 1
|
||||
};
|
||||
Ok(pos)
|
||||
let contents = convert_reference_contents(registry.clone(), definition).await?;
|
||||
{
|
||||
let mut registry = registry.lock().unwrap();
|
||||
let entry = registry
|
||||
.footnote_ids
|
||||
.get_mut(existing_id)
|
||||
.expect("If-statement proves this to be Some.");
|
||||
entry.1 = contents;
|
||||
}
|
||||
Ok(existing_id)
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,9 +171,20 @@ pub(crate) async fn promote_footnote_definition<'orig, 'parse>(
|
||||
definition
|
||||
};
|
||||
if let Some(elements) = definition {
|
||||
let existing_id = {
|
||||
let mut registry = registry.lock().unwrap();
|
||||
registry.footnote_ids.push((Some(label), Vec::new()));
|
||||
registry.footnote_ids.len() - 1
|
||||
};
|
||||
let contents = convert_definition_contents(registry.clone(), elements).await?;
|
||||
let mut registry = registry.lock().unwrap();
|
||||
registry.footnote_ids.push((Some(label), contents));
|
||||
{
|
||||
let mut registry = registry.lock().unwrap();
|
||||
let entry = registry
|
||||
.footnote_ids
|
||||
.get_mut(existing_id)
|
||||
.expect("If-statement proves this to be Some.");
|
||||
entry.1 = contents;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user