code clean
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled

This commit is contained in:
philipp 2024-02-15 18:44:21 +01:00
parent f97dd7bde2
commit 06651dc878
2 changed files with 23 additions and 41 deletions

View File

@ -32,12 +32,10 @@ impl Abschnitt {
Self::skip_static_fields(&mut c);
if !ret.handle_headers(&mut c, builder) {
return ret;
}
ret.handle_headers(&mut c, builder);
while let Some(child) = c.peek() {
// Shciffahrtsgesetz: stop @ anlagen (for now)
// Schiffahrtsgesetz: stop @ anlagen (for now)
if Ueberschrift::test(child, "anlage") {
return ret;
}
@ -202,12 +200,8 @@ impl Abschnitt {
// There are paragraph-specific meta-data at the top of each xml file. We parse those. When we
// encounter the title "Text" the real content starts, we stop parsing meta data.
//
// # Returns
// `false` if the parsing should be stopped
fn handle_headers(&mut self, c: &mut Peekable<Children>, builder: &mut LawBuilder) -> bool {
while let Some(child) = &c.peek() {
if Ueberschrift::test(child, "titel") {
fn handle_headers(&mut self, c: &mut Peekable<Children>, builder: &mut LawBuilder) {
loop {
let key = Ueberschrift::parse(c.next().unwrap(), "titel").content;
// We are done with meta-data parsing
@ -219,12 +213,7 @@ impl Abschnitt {
c.next()
.expect("Expected absatz after title in par headers"),
);
if &absatz.typ != "erltext" {
panic!(
"Expected erlext absatz after title in par headers, got '{}'",
absatz.typ
);
}
let value = absatz.content;
// We want ot use this information in our markdown output.
@ -236,10 +225,6 @@ impl Abschnitt {
self.metadata.insert(key, value);
continue;
}
panic!("Something unforeseen happened")
}
true
}
// At the beginning of each 'Abschnitt' there are 4 static fields. Since they don't provide any

View File

@ -406,9 +406,6 @@ impl Ueberschrift {
fn test(n: &Node, typ: &str) -> bool {
n.tag_name().name() == "ueberschrift" && n.attribute("typ").unwrap() == typ
}
fn test_with_typ_and_content(n: &Node, typ: &str, content: &str) -> bool {
Self::test(n, typ) && n.text().unwrap() == content
}
pub(crate) fn parse(n: Node, typ: &str) -> Self {
assert!(n.tag_name().name() == "ueberschrift");