extract to table rs
All checks were successful
CI/CD Pipeline / test (push) Successful in 1m49s

This commit is contained in:
2024-02-16 09:54:38 +01:00
parent bb8e5641f6
commit 04cc7d9183
4 changed files with 77 additions and 83 deletions

View File

@ -16,6 +16,7 @@
mod abschnitt;
mod liste;
mod table;
use abschnitt::Abschnitt;
use roxmltree::Node;
@ -216,41 +217,6 @@ impl Tr {
Self { tds }
}
}
#[derive(Debug, PartialEq)]
pub(crate) struct Table {
trs: Vec<Tr>,
}
impl Table {
pub(crate) fn test(n: &Node) -> bool {
n.tag_name().name() == "table"
}
pub(crate) fn parse(n: Node) -> Self {
assert!(Self::test(&n));
let mut trs = Vec::new();
for child in n.children() {
trs.push(Tr::parse(&child));
}
Self { trs }
}
pub(crate) fn get_list(&self) -> Vec<Content> {
let mut ret = Vec::new();
for tr in &self.trs {
let mut txt = String::new();
for td in &tr.tds {
txt.push_str(&format!("{} ", td.absatz.content));
}
ret.push(Content::Text(format!("- {txt}",)));
}
ret
}
}
#[derive(Debug, PartialEq)]
pub(crate) struct Schlussteil {