remove extra conditions

This commit is contained in:
yggverse 2024-12-03 19:42:13 +02:00
parent f08ae77b7c
commit b4d9686db5
3 changed files with 13 additions and 27 deletions

View file

@ -26,27 +26,15 @@ impl Header {
RegexMatchFlags::DEFAULT, RegexMatchFlags::DEFAULT,
); );
// Detect header level
let level = regex.get(1)?;
let level = match level.len() {
1 => Level::H1,
2 => Level::H2,
3 => Level::H3,
_ => return None,
};
// Detect header value
let value = regex.get(2)?.trim();
if value.is_empty() {
return None;
}
// Result // Result
Some(Self { Some(Self {
level, level: match regex.get(1)?.len() {
value: value.to_string(), 1 => Level::H1,
2 => Level::H2,
3 => Level::H3,
_ => return None,
},
value: regex.get(2)?.trim().to_string(),
}) })
} }
} }

View file

@ -19,9 +19,8 @@ impl List {
); );
// Extract formatted value // Extract formatted value
let value = regex.get(1)?.trim().to_string(); Some(Self {
value: regex.get(1)?.trim().to_string(),
// Result })
Some(Self { value })
} }
} }

View file

@ -19,9 +19,8 @@ impl Quote {
); );
// Extract formatted value // Extract formatted value
let value = regex.get(1)?.trim().to_string(); Some(Self {
value: regex.get(1)?.trim().to_string(),
// Result })
Some(Self { value })
} }
} }