don't add a td if it's only used for styling

This commit is contained in:
philipp 2024-10-07 22:24:59 +02:00
parent 172215abaa
commit 1b49ba1314

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 }