diff options
author | HampusM <hampus@hampusmat.com> | 2023-03-01 21:50:13 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2023-03-01 21:50:13 +0100 |
commit | 656ca92bc5958752d6a12e2a659fe17809fe5e86 (patch) | |
tree | cdfbc60fe24e865a46b800ff3506db6a6640283f /src/description.rs | |
parent | b1424312a932f345f86a93aba662add645fcf921 (diff) |
feat: add informal table support
Diffstat (limited to 'src/description.rs')
-rw-r--r-- | src/description.rs | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/description.rs b/src/description.rs index f6e0f70..5d0cb1f 100644 --- a/src/description.rs +++ b/src/description.rs @@ -1,4 +1,5 @@ //! Reference entry description. +use crate::informal_table::{Error as InformalTableError, InformalTable}; use crate::itemized_list::{Error as ItemizedListError, ItemizedList}; use crate::variable_list::{Error as VariableListError, VariableList}; use crate::xml::element::{Element, Elements, FromElements, Tagged}; @@ -95,6 +96,11 @@ impl FromElements for Description .cloned() .unwrap_or_default(), ))), + "informaltable" => Some( + InformalTable::from_elements(part_elem.child_elements()) + .map(Part::InformalTable) + .map_err(Self::Error::InvalidInformalTable), + ), "title" => None, name => Some(Err(Self::Error::UnknownPartFound(name.to_string()))), }) @@ -122,6 +128,10 @@ pub enum Error /// Invalid variable list. #[error("Invalid variable list")] InvalidVariableList(#[source] VariableListError), + + /// Invalid informal table. + #[error("Invalid informal table")] + InvalidInformalTable(#[source] InformalTableError), } /// Description part. @@ -136,6 +146,9 @@ pub enum Part /// Program listing. ProgramListing(String), + + /// Informal table. + InformalTable(InformalTable), } /// Reference entry description paragraph. @@ -231,6 +244,9 @@ pub enum ParagraphPart /// Itemized list part. ItemizedList(ItemizedList), + + /// Informal table part. + InformalTable(InformalTable), } impl FromElements for ParagraphPart @@ -266,7 +282,7 @@ impl ParagraphPart "inlineequation" => Self::InlineEquation, "programlisting" => Self::ProgramListing, "citerefentry" => Self::Entry, - "variablelist" | "itemizedlist" => |_| { + "variablelist" | "itemizedlist" | "informaltable" => |_| { unreachable!(); }, _ => { @@ -304,6 +320,15 @@ impl ParagraphPart return Ok(Self::ItemizedList(itemized_list)); } + if tagged_element.name() == "informaltable" { + let informal_table = InformalTable::from_elements( + tagged_element.child_elements(), + ) + .map_err(|err| ParagraphPartError::InvalidInformalTable(Box::new(err)))?; + + return Ok(Self::InformalTable(informal_table)); + } + if tagged_element.name() == "inlineequation" { return Ok(Self::InlineEquation( tagged_element @@ -350,4 +375,8 @@ pub enum ParagraphPartError /// Invalid itemized list. #[error("Invalid itemized list")] InvalidItemizedList(#[from] ItemizedListError), + + /// Invalid informal table. + #[error("Invalid informal table")] + InvalidInformalTable(#[source] Box<InformalTableError>), } |