add vereinsgesetz; add optional 'beachte' text for paragraphs
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled

This commit is contained in:
2024-02-15 13:12:00 +01:00
parent a32b3a66c7
commit eb8af55554
7 changed files with 92 additions and 4 deletions

View File

@ -76,7 +76,24 @@ impl Abschnitt {
Fzinhalt::parse(c.next().unwrap());
// Skip all UeberschriftTitle and Absatz
while let Some(child) = c.peek() {
while let Some(child) = &c.peek() {
if Ueberschrift::test_with_typ_and_content(child, "titel", "Beachte") {
c.next();
//<absatz typ="erltext" ct="beachte" halign="j">Zu Abs. 2: zum Bezugszeitraum vgl. § 33 Abs. 13</absatz>
let absatz = Absatz::parse(
c.next()
.expect("After a 'Beachte' title, we need an Absatz"),
);
println!("{}", absatz.typ);
if absatz.typ != "erltext".to_string() {
panic!("Expected erltext absatz after 'Beachte'");
}
builder.add_next_para_note(absatz.content);
continue;
}
if Ueberschrift::test(child, "titel") {
c.next();
continue;
@ -508,6 +525,7 @@ impl Leaf {
#[derive(Debug, PartialEq)]
pub(crate) struct Absatz {
content: String,
typ: String,
}
impl Absatz {
pub(crate) fn test(n: &Node) -> bool {
@ -523,10 +541,12 @@ impl Absatz {
if let Some(text) = n.text() {
Self {
content: text.into(),
typ: n.attribute("typ").unwrap().into(),
}
} else {
Self {
content: String::new(),
typ: n.attribute("typ").unwrap().into(),
}
}
}
@ -541,6 +561,9 @@ 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");