This commit is contained in:
@ -39,10 +39,25 @@ impl Liste {
|
||||
|
||||
let mut c = n.next().unwrap().children().peekable();
|
||||
|
||||
let mut last_ebene: Option<usize> = None;
|
||||
|
||||
// Parse stuff inside <liste>
|
||||
while let Some(child) = c.peek() {
|
||||
if Ziffernliste::test(child) {
|
||||
content.push(Ziffernliste::parse(c.next().unwrap()).get_content());
|
||||
let liste = Ziffernliste::parse(c.next().unwrap());
|
||||
let mut already_added = false;
|
||||
if let Some(last) = last_ebene {
|
||||
if liste.ebene > last {
|
||||
let last_list = content.pop().unwrap();
|
||||
content.push(Content::List(vec![last_list, liste.get_content()]));
|
||||
already_added = true;
|
||||
}
|
||||
}
|
||||
|
||||
last_ebene = Some(liste.ebene);
|
||||
if !already_added {
|
||||
content.push(liste.get_content());
|
||||
}
|
||||
} else if Schlussteil::test(child) {
|
||||
// 162 Schifffahrtsgesetz show use that a 'schlussteil' can be at the start of a list
|
||||
content.push(Content::Text(Schlussteil::parse(c.next().unwrap()).content));
|
||||
|
@ -148,7 +148,7 @@ impl Listelem {
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub(crate) struct Ziffernliste {
|
||||
ebene: String,
|
||||
ebene: usize,
|
||||
listelems: Vec<Listelem>,
|
||||
}
|
||||
impl Ziffernliste {
|
||||
@ -160,7 +160,7 @@ impl Ziffernliste {
|
||||
pub(crate) fn parse(n: Node) -> Self {
|
||||
assert!(Self::test(&n));
|
||||
|
||||
let ebene = n.attribute("ebene").unwrap().into();
|
||||
let ebene = n.attribute("ebene").unwrap().parse::<usize>().unwrap();
|
||||
|
||||
let mut listelems = Vec::new();
|
||||
|
||||
|
Reference in New Issue
Block a user