extract absatz
All checks were successful
CI/CD Pipeline / test (push) Successful in 1m48s

This commit is contained in:
2024-02-16 10:37:17 +01:00
parent d07bc726b9
commit 76ddf9796b
3 changed files with 78 additions and 72 deletions

View File

@ -14,6 +14,7 @@
// See the Licence for the specific language governing permissions and
// limitations under the Licence.
mod absatz;
mod abschnitt;
mod liste;
mod table;
@ -24,6 +25,7 @@ use roxmltree::Node;
use crate::{
law::{Content, LawBuilder},
misc::Error,
paragraph::parser::absatz::Absatz,
};
struct Expect<'a> {
@ -289,34 +291,6 @@ impl Leaf {
n.text().unwrap().into()
}
}
#[derive(Debug, PartialEq)]
pub(crate) struct Absatz {
content: String,
typ: String,
}
impl Absatz {
pub(crate) fn test_with_typ(n: &Node, typ: &str) -> bool {
n.tag_name().name() == "absatz" && n.attribute("typ") == Some(typ)
}
pub(crate) fn parse(n: Node) -> Self {
Expect::from(&n).tag("absatz");
let typ = n.attribute("typ").unwrap().into();
let mut content = String::new();
// Get text from this element + all direct childs
for c in n.children() {
if let Some(text) = c.text() {
content.push_str(text);
}
}
Self { content, typ }
}
}
#[derive(Debug, PartialEq)]
pub(crate) struct Ueberschrift {
typ: String,