add vereinsgesetz; add optional 'beachte' text for paragraphs
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
This commit is contained in:
@ -128,6 +128,8 @@ pub struct LawBuilder {
|
||||
/// Stores the header of the next paragraph
|
||||
next_para_header: Option<String>,
|
||||
|
||||
next_para_note: Option<String>,
|
||||
|
||||
#[cfg(test)]
|
||||
pub history: Vec<String>,
|
||||
}
|
||||
@ -154,6 +156,7 @@ impl LawBuilder {
|
||||
header: Vec::new(),
|
||||
next_para_header: None,
|
||||
last_instance: None,
|
||||
next_para_note: None,
|
||||
#[cfg(test)]
|
||||
history: Vec::new(),
|
||||
}
|
||||
@ -261,6 +264,9 @@ impl LawBuilder {
|
||||
let par_header = self.next_para_header.clone();
|
||||
self.next_para_header = None;
|
||||
|
||||
let par_note = self.next_para_note.clone();
|
||||
self.next_para_note = None;
|
||||
|
||||
self.last_instance
|
||||
.clone()
|
||||
.expect("Expect at least one classifier")
|
||||
@ -268,6 +274,7 @@ impl LawBuilder {
|
||||
.add_section(Section {
|
||||
symb: par,
|
||||
par_header,
|
||||
par_note,
|
||||
content,
|
||||
});
|
||||
}
|
||||
@ -284,12 +291,20 @@ impl LawBuilder {
|
||||
debug!("new_next_para_header={header}");
|
||||
self.next_para_header = Some(header.trim().into());
|
||||
}
|
||||
|
||||
pub fn add_next_para_note(&mut self, content: String) {
|
||||
#[cfg(test)]
|
||||
self.history.push(format!("New_para_note: {content}"));
|
||||
|
||||
self.next_para_note = Some(content);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Section {
|
||||
pub symb: String, // §"1", §"2", ...
|
||||
pub par_header: Option<String>,
|
||||
pub par_note: Option<String>,
|
||||
pub content: Content,
|
||||
}
|
||||
|
||||
@ -302,11 +317,16 @@ impl fmt::Debug for Section {
|
||||
|
||||
impl fmt::Display for Section {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if let Some(header) = &self.par_header {
|
||||
f.write_str(&format!("{} ({})\n{}", self.symb, header, self.content))
|
||||
let mut to_write = if let Some(header) = &self.par_header {
|
||||
format!("{} ({})\n{}", self.symb, header, self.content)
|
||||
} else {
|
||||
f.write_str(&format!("{}\n{}", self.symb, self.content))
|
||||
format!("{}\n{}", self.symb, self.content)
|
||||
};
|
||||
if let Some(note) = &self.par_note {
|
||||
to_write.push_str(&format!("\nBeachte: {}", note));
|
||||
}
|
||||
|
||||
f.write_str(&to_write)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user