use crate::body::{NoteId, NoteMark};
use crate::note_setup::NoteLabel;
use super::Layout;
#[cfg(test)]
mod tests;
impl Layout<'_> {
pub(super) fn endnote_label(&mut self, reference: Option<(NoteId, NoteMark)>) -> NoteLabel {
let Some((id, mark)) = reference else {
return self.endnote.unwrap_or(NoteLabel {
value: 1,
format: self.settings.notes.endnotes.format,
});
};
if let Some(note) = self.output.endnotes.iter().find(|note| note.id == id) {
return note.label;
}
let setup = self.section_layout(self.section_index).notes.endnotes;
let note = self.numbered_note((id, mark), &self.output.endnotes, setup, None);
let label = note.label;
self.output.endnotes.push(note);
label
}
pub(super) fn endnotes_flow(&mut self) {
if self.output.endnotes.is_empty() {
return;
}
let separator = self.context.endnotes.separator.clone();
self.output.story_parts.current = super::StoryPart::Endnotes;
self.blocks(&separator);
let notes = self.output.endnotes.clone();
for note in ¬es {
let Some(blocks) = self.context.endnotes.by_id.get(¬e.id).cloned() else {
continue;
};
self.endnote = Some(note.label);
self.blocks(&blocks);
}
self.endnote = None;
self.output.story_parts.current = super::StoryPart::Own;
}
}