Compare commits

..

2 Commits

Author SHA1 Message Date
4540cedde6 add ug
All checks were successful
CI/CD Pipeline / test (push) Successful in 2m12s
2024-10-07 22:25:03 +02:00
1b49ba1314 don't add a td if it's only used for styling 2024-10-07 22:24:59 +02:00
2 changed files with 42 additions and 4 deletions

32
data/configs/ug.toml Normal file
View File

@ -0,0 +1,32 @@
[law]
id = 20002128
name = "Universitätsgesetz 2002"
[[law.classifiers]]
name = "Teil"
is_root = true
match_function = "contains"
[[law.classifiers]]
name = " Abschnitt"
is_root = false
match_function = "contains"
[[law.classifiers]]
name = "Unterabschnitt"
is_root = false
match_function = "contains"
[parser]
remove_strings = [
"<n>", "</n>",
"""<abstand ct="text" halign="l" />""",
"<br />",
"<i>", "</i>",
"<u>", "</u>"
]
[[parser.replace_rules]]
find = "<gdash />" # Should be at the same level as the other "Theil"e
replace_with = "-"

View File

@ -297,15 +297,19 @@ pub(crate) struct Td {
absatz: Absatz, absatz: Absatz,
} }
impl Td { impl Td {
pub(crate) fn parse(n: &Node) -> Self { /// Returns `None` if td doesn't contain anything. used e.g. in § 71b to style table...
pub(crate) fn parse(n: &Node) -> Option<Self> {
Expect::from(n).tag("td"); Expect::from(n).tag("td");
let mut c = n.children(); let mut c = n.children();
let absatz = Absatz::parse(c.next().unwrap());
let Some(next) = c.next() else { return None };
let absatz = Absatz::parse(next);
Expect::empty(c.next()); Expect::empty(c.next());
Self { absatz } Some(Self { absatz })
} }
} }
@ -320,7 +324,9 @@ impl Tr {
let mut tds = Vec::new(); let mut tds = Vec::new();
for child in n.children() { for child in n.children() {
tds.push(Td::parse(&child)); if let Some(td) = Td::parse(&child) {
tds.push(td);
}
} }
Self { tds } Self { tds }