This commit is contained in:
@ -15,6 +15,7 @@
|
||||
// limitations under the Licence.
|
||||
|
||||
mod abschnitt;
|
||||
mod liste;
|
||||
|
||||
use abschnitt::Abschnitt;
|
||||
use roxmltree::Node;
|
||||
@ -270,53 +271,6 @@ impl Schlussteil {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct Liste {
|
||||
content: Vec<Content>,
|
||||
}
|
||||
impl Liste {
|
||||
pub(crate) fn test(n: &Node) -> bool {
|
||||
n.tag_name().name() == "liste"
|
||||
}
|
||||
|
||||
pub(crate) fn parse(n: Node) -> Self {
|
||||
assert!(Self::test(&n));
|
||||
|
||||
let mut content = Vec::new();
|
||||
|
||||
let mut c = n.children().peekable();
|
||||
|
||||
// 162 Schifffahrtsgesetz show use that a 'schlussteil' can be at the start of a list
|
||||
while let Some(child) = c.peek() {
|
||||
if Schlussteil::test(child) {
|
||||
content.push(Content::Text(Schlussteil::parse(c.next().unwrap()).content));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
content.push(Ziffernliste::parse(c.next().unwrap()).get_content());
|
||||
|
||||
while let Some(child) = c.peek() {
|
||||
if Ziffernliste::test(child) {
|
||||
content.push(Ziffernliste::parse(c.next().unwrap()).get_content());
|
||||
} else if Schlussteil::test(child) {
|
||||
content.push(Content::Text(Schlussteil::parse(c.next().unwrap()).content));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assert_eq!(c.next(), None);
|
||||
|
||||
Self { content }
|
||||
}
|
||||
|
||||
pub(crate) fn get_content(&self) -> Content {
|
||||
Content::List(self.content.clone())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub(crate) struct AbsatzAbs {
|
||||
gldsym: Option<String>,
|
||||
|
Reference in New Issue
Block a user