summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/description.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/description.rs b/src/description.rs
index e7cb951..f6e0f70 100644
--- a/src/description.rs
+++ b/src/description.rs
@@ -1,7 +1,7 @@
//! Reference entry description.
use crate::itemized_list::{Error as ItemizedListError, ItemizedList};
use crate::variable_list::{Error as VariableListError, VariableList};
-use crate::xml::element::{Elements, FromElements, Tagged};
+use crate::xml::element::{Element, Elements, FromElements, Tagged};
/// Reference entry description.
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -171,8 +171,14 @@ impl FromElements for Paragraph
{
let parts = elements
.into_iter()
- .map(|element| {
- ParagraphPart::from_elements(&Elements::from([element.clone()]))
+ .filter_map(|element| {
+ if matches!(element, Element::Comment(_)) {
+ return None;
+ }
+
+ Some(ParagraphPart::from_elements(&Elements::from([
+ element.clone()
+ ])))
})
.collect::<Result<Vec<_>, _>>()?;
@@ -239,7 +245,7 @@ impl FromElements for ParagraphPart
let text = elements
.get_first_text_element()
- .ok_or(Self::Error::InputIsComment)?;
+ .ok_or(Self::Error::ExpectedTextElement)?;
Ok(Self::Text(text.clone()))
}
@@ -321,9 +327,9 @@ impl ParagraphPart
#[derive(Debug, thiserror::Error)]
pub enum ParagraphPartError
{
- /// Input element is a comment.
- #[error("Input element is a comment")]
- InputIsComment,
+ /// Expected a text element.
+ #[error("Expected a text element")]
+ ExpectedTextElement,
/// A input element is a unknown description part.
#[error("Input element with name '{0}' is a unknown description part")]