use crate::error::CustomError; use super::ast_node::IAstNode; use super::registry::Registry; use super::IElement; use super::IObject; #[derive(Debug, Clone)] pub(crate) struct IFootnoteDefinition {} impl IFootnoteDefinition { pub(crate) async fn new<'b, 'parse>( registry: &'b mut Registry<'parse>, original: &'b organic::types::FootnoteDefinition<'parse>, ) -> Result { registry .register_footnote_definition(original.label, &original.children) .await?; Ok(IFootnoteDefinition {}) } } #[derive(Debug)] pub(crate) struct IRealFootnoteDefinition { pub(crate) footnote_id: usize, pub(crate) contents: Vec, } impl IRealFootnoteDefinition { pub(crate) async fn new<'b, 'parse>( registry: &'b mut Registry<'parse>, footnote_id: usize, contents: Vec, ) -> Result { Ok(IRealFootnoteDefinition { footnote_id, contents, }) } pub(crate) fn get_display_label(&self) -> String { format!("{}", self.footnote_id + 1) } /// Get an ID to refer to the first reference to this footnote definition. /// /// This ID could, for example, be used for the id attribute in HTML for the reference anchor tag. pub(crate) fn get_reference_id(&self) -> String { format!("fnr.{}", self.get_display_label()) } /// Get an ID to refer to the footnote definition. /// /// This ID could, for example, be used for the id attribute in HTML for the definition anchor tag. pub(crate) fn get_definition_id(&self) -> String { format!("fn.{}", self.get_display_label()) } }