remove list of list etc
All checks were successful
CI/CD Pipeline / test (push) Successful in 2m5s

This commit is contained in:
2024-02-17 16:43:04 +01:00
parent 1732f40534
commit 4317f79d0c
13 changed files with 239 additions and 225 deletions

View File

@ -334,7 +334,7 @@ pub struct Section {
impl fmt::Debug for Section {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let par_header = self.par_header.as_deref().unwrap_or("");
write!(f, "{} ({})", self.symb, par_header)
write!(f, "{} ({})\n{:#?}", self.symb, par_header, self.content)
}
}
@ -458,13 +458,23 @@ impl std::fmt::Debug for Classifier {
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, PartialEq, Serialize, Deserialize)]
pub enum Content {
Text(String), //This is my direct law text
Item(Vec<Content>), //(1) This is general law. (2) This is more specific law
List(Vec<Content>),
}
impl std::fmt::Debug for Content {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Text(arg0) => f.debug_tuple("Text").field(arg0).finish(),
Self::Item(arg0) => f.debug_tuple("Item").field(arg0).finish(),
Self::List(arg0) => f.debug_tuple("List").field(arg0).finish(),
}
}
}
impl Display for Content {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {

View File

@ -57,7 +57,7 @@ fn main() {
builder.new_header("initial");
parser.parse(par_url, &mut builder).unwrap();
let law: Law = builder.into();
law.to_md();
println!("{law:?}");
} else {
let law = Law::from_config(&args.config).unwrap();
law.to_md();

View File

@ -63,6 +63,10 @@ impl Liste {
}
pub(crate) fn get_content(&self) -> Content {
Content::List(self.content.clone())
if self.content.len() == 1 {
self.content[0].clone()
} else {
Content::List(self.content.clone())
}
}
}