From f576587f8b872b6369c7079055944977f2293e5c Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 4 Mar 2023 12:41:48 +0100 Subject: feat: add footnote paragraph part support --- src/description.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/description.rs b/src/description.rs index 3697673..e6cd1cd 100644 --- a/src/description.rs +++ b/src/description.rs @@ -262,6 +262,9 @@ pub enum ParagraphPart /// Paragraph part. Paragraph(Paragraph), + + /// Footnote part. + Footnote(Paragraph), } impl FromElements for ParagraphPart @@ -297,9 +300,11 @@ impl ParagraphPart "inlineequation" => Self::InlineEquation, "programlisting" => Self::ProgramListing, "citerefentry" => Self::Entry, - "variablelist" | "itemizedlist" | "informaltable" | "para" => |_| { - unreachable!(); - }, + "variablelist" | "itemizedlist" | "informaltable" | "para" | "footnote" => { + |_| { + unreachable!(); + } + } _ => { return Err(::Error::UnknownPart( tagged_element.name().to_string(), @@ -361,6 +366,13 @@ impl ParagraphPart )); } + if tagged_element.name() == "footnote" { + return Ok(Self::Footnote( + Paragraph::from_elements(tagged_element.child_elements()) + .map_err(|err| ParagraphPartError::InvalidFootnote(Box::new(err)))?, + )); + } + let text_element = tagged_element .child_elements() .get_first_text_element() @@ -405,4 +417,8 @@ pub enum ParagraphPartError /// Invalid paragraph. #[error("Invalid paragraph")] InvalidParagraph(#[source] Box), + + /// Invalid footnote. + #[error("Invalid footnote")] + InvalidFootnote(#[source] Box), } -- cgit v1.2.3-18-g5258