lib: make div class non option
there is no distinction between an empty class and a None
This commit is contained in:
parent
116fb04725
commit
924a3c35bb
2 changed files with 13 additions and 16 deletions
15
src/html.rs
15
src/html.rs
|
@ -208,14 +208,11 @@ impl<'s> Writer<'s> {
|
|||
if attrs.iter().any(|(a, _)| a == "class")
|
||||
|| matches!(
|
||||
c,
|
||||
Container::Div { class: Some(_) }
|
||||
| Container::Math { .. }
|
||||
| Container::List {
|
||||
Container::Div { class } if !class.is_empty())
|
||||
|| matches!(c, |Container::Math { .. }| Container::List {
|
||||
kind: ListKind::Task,
|
||||
..
|
||||
}
|
||||
| Container::TaskListItem { .. }
|
||||
)
|
||||
} | Container::TaskListItem { .. })
|
||||
{
|
||||
out.write_str(r#" class=""#)?;
|
||||
let mut first_written = false;
|
||||
|
@ -246,11 +243,13 @@ impl<'s> Writer<'s> {
|
|||
.try_for_each(|part| write_attr(part, &mut out))?;
|
||||
}
|
||||
// div class goes after classes from attrs
|
||||
if let Container::Div { class: Some(cls) } = c {
|
||||
if let Container::Div { class } = c {
|
||||
if !class.is_empty() {
|
||||
if first_written {
|
||||
out.write_char(' ')?;
|
||||
}
|
||||
out.write_str(cls)?;
|
||||
out.write_str(class)?;
|
||||
}
|
||||
}
|
||||
out.write_char('"')?;
|
||||
}
|
||||
|
|
|
@ -270,7 +270,7 @@ pub enum Container<'s> {
|
|||
/// A section belonging to a top level heading.
|
||||
Section { id: CowStr<'s> },
|
||||
/// A block-level divider element.
|
||||
Div { class: Option<&'s str> },
|
||||
Div { class: &'s str },
|
||||
/// A paragraph.
|
||||
Paragraph,
|
||||
/// A heading.
|
||||
|
@ -919,9 +919,7 @@ impl<'s> Parser<'s> {
|
|||
}
|
||||
block::Node::Container(c) => match c {
|
||||
block::Container::Blockquote => Container::Blockquote,
|
||||
block::Container::Div { .. } => Container::Div {
|
||||
class: (!ev.span.is_empty()).then(|| content),
|
||||
},
|
||||
block::Container::Div => Container::Div { class: content },
|
||||
block::Container::Footnote => Container::Footnote { label: content },
|
||||
block::Container::List(block::ListKind { ty, tight }) => {
|
||||
if matches!(ty, block::ListType::Description) {
|
||||
|
|
Loading…
Reference in a new issue