summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-03-04 12:41:48 +0100
committerHampusM <hampus@hampusmat.com>2023-03-04 12:41:48 +0100
commitf576587f8b872b6369c7079055944977f2293e5c (patch)
tree08b3c984009fa7274ab824e8fbee0dd457f737af /src
parentb825e4cb42884cea3a7e8bf0ff74183a326f5d1b (diff)
feat: add footnote paragraph part support
Diffstat (limited to 'src')
-rw-r--r--src/description.rs22
1 files 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(<Self as FromElements>::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<ParagraphError>),
+
+ /// Invalid footnote.
+ #[error("Invalid footnote")]
+ InvalidFootnote(#[source] Box<ParagraphError>),
}