This commit is contained in:
parent
f97dd7bde2
commit
06651dc878
@ -32,12 +32,10 @@ impl Abschnitt {
|
|||||||
|
|
||||||
Self::skip_static_fields(&mut c);
|
Self::skip_static_fields(&mut c);
|
||||||
|
|
||||||
if !ret.handle_headers(&mut c, builder) {
|
ret.handle_headers(&mut c, builder);
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
while let Some(child) = c.peek() {
|
while let Some(child) = c.peek() {
|
||||||
// Shciffahrtsgesetz: stop @ anlagen (for now)
|
// Schiffahrtsgesetz: stop @ anlagen (for now)
|
||||||
if Ueberschrift::test(child, "anlage") {
|
if Ueberschrift::test(child, "anlage") {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -202,44 +200,31 @@ impl Abschnitt {
|
|||||||
|
|
||||||
// There are paragraph-specific meta-data at the top of each xml file. We parse those. When we
|
// 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.
|
// encounter the title "Text" the real content starts, we stop parsing meta data.
|
||||||
//
|
fn handle_headers(&mut self, c: &mut Peekable<Children>, builder: &mut LawBuilder) {
|
||||||
// # Returns
|
loop {
|
||||||
// `false` if the parsing should be stopped
|
let key = Ueberschrift::parse(c.next().unwrap(), "titel").content;
|
||||||
fn handle_headers(&mut self, c: &mut Peekable<Children>, builder: &mut LawBuilder) -> bool {
|
|
||||||
while let Some(child) = &c.peek() {
|
|
||||||
if Ueberschrift::test(child, "titel") {
|
|
||||||
let key = Ueberschrift::parse(c.next().unwrap(), "titel").content;
|
|
||||||
|
|
||||||
// We are done with meta-data parsing
|
// We are done with meta-data parsing
|
||||||
if key == "Text" {
|
if key == "Text" {
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
let absatz = Absatz::parse(
|
|
||||||
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.
|
|
||||||
// TODO: Use all metadata, instead of this specific call
|
|
||||||
if key == "Beachte" {
|
|
||||||
builder.add_next_para_note(value.clone());
|
|
||||||
}
|
|
||||||
|
|
||||||
self.metadata.insert(key, value);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
panic!("Something unforeseen happened")
|
let absatz = Absatz::parse(
|
||||||
|
c.next()
|
||||||
|
.expect("Expected absatz after title in par headers"),
|
||||||
|
);
|
||||||
|
|
||||||
|
let value = absatz.content;
|
||||||
|
|
||||||
|
// We want ot use this information in our markdown output.
|
||||||
|
// TODO: Use all metadata, instead of this specific call
|
||||||
|
if key == "Beachte" {
|
||||||
|
builder.add_next_para_note(value.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
self.metadata.insert(key, value);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// At the beginning of each 'Abschnitt' there are 4 static fields. Since they don't provide any
|
// At the beginning of each 'Abschnitt' there are 4 static fields. Since they don't provide any
|
||||||
|
@ -406,9 +406,6 @@ impl Ueberschrift {
|
|||||||
fn test(n: &Node, typ: &str) -> bool {
|
fn test(n: &Node, typ: &str) -> bool {
|
||||||
n.tag_name().name() == "ueberschrift" && n.attribute("typ").unwrap() == typ
|
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 {
|
pub(crate) fn parse(n: Node, typ: &str) -> Self {
|
||||||
assert!(n.tag_name().name() == "ueberschrift");
|
assert!(n.tag_name().name() == "ueberschrift");
|
||||||
|
Loading…
Reference in New Issue
Block a user