add schlussteile to appropriate lists
All checks were successful
CI/CD Pipeline / test (push) Successful in 1m56s
All checks were successful
CI/CD Pipeline / test (push) Successful in 1m56s
This commit is contained in:
@ -155,6 +155,7 @@ pub(crate) struct Ziffernliste {
|
||||
ebene: usize,
|
||||
listelems: Vec<Listelem>,
|
||||
sublist: Option<Box<Ziffernliste>>,
|
||||
schlussteile: Vec<Schlussteil>,
|
||||
}
|
||||
impl Ziffernliste {
|
||||
pub(crate) fn test(n: &Node) -> bool {
|
||||
@ -193,10 +194,20 @@ impl Ziffernliste {
|
||||
}
|
||||
}
|
||||
|
||||
let mut schlussteile = Vec::new();
|
||||
while let Some(child) = c.peek() {
|
||||
if Schlussteil::test_with_ebene(child, ebene) {
|
||||
schlussteile.push(Schlussteil::parse(c.next().unwrap()));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Self {
|
||||
ebene,
|
||||
listelems,
|
||||
sublist,
|
||||
schlussteile,
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,6 +227,10 @@ impl Ziffernliste {
|
||||
elems.push(sublist.get_content());
|
||||
}
|
||||
|
||||
for schlussteil in &self.schlussteile {
|
||||
elems.push(Content::Text(schlussteil.content.clone()));
|
||||
}
|
||||
|
||||
Content::List(elems)
|
||||
}
|
||||
}
|
||||
@ -255,15 +270,21 @@ impl Tr {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub(crate) struct Schlussteil {
|
||||
content: String,
|
||||
pub(crate) content: String,
|
||||
}
|
||||
impl Schlussteil {
|
||||
pub(crate) fn test(n: &Node) -> bool {
|
||||
(n.tag_name().name() == "schlussteil" || n.tag_name().name() == "schluss")
|
||||
&& n.children().count() == 1
|
||||
}
|
||||
pub(crate) fn test_with_ebene(n: &Node, level: usize) -> bool {
|
||||
match n.attribute("ebene") {
|
||||
Some(ebene) => Self::test(n) && ebene == level.to_string(),
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn parse(n: Node) -> Self {
|
||||
assert!(Self::test(&n));
|
||||
|
Reference in New Issue
Block a user