block: specify div class in event
instead of using span
This commit is contained in:
parent
6cebdfcc0c
commit
898ed90a24
2 changed files with 9 additions and 7 deletions
14
src/block.rs
14
src/block.rs
|
@ -85,7 +85,7 @@ pub enum Container<'s> {
|
||||||
Blockquote,
|
Blockquote,
|
||||||
|
|
||||||
/// Span is class specifier, possibly empty.
|
/// Span is class specifier, possibly empty.
|
||||||
Div,
|
Div { class: &'s str },
|
||||||
|
|
||||||
/// Span is the list marker of the first list item in the list.
|
/// Span is the list marker of the first list item in the list.
|
||||||
List { kind: ListKind, marker: &'s str },
|
List { kind: ListKind, marker: &'s str },
|
||||||
|
@ -269,7 +269,9 @@ impl<'s> TreeParser<'s> {
|
||||||
Kind::Fenced {
|
Kind::Fenced {
|
||||||
kind: FenceKind::Div,
|
kind: FenceKind::Div,
|
||||||
..
|
..
|
||||||
} => Block::Container(Div),
|
} => Block::Container(Div {
|
||||||
|
class: span.of(self.src),
|
||||||
|
}),
|
||||||
Kind::Definition {
|
Kind::Definition {
|
||||||
footnote: false, ..
|
footnote: false, ..
|
||||||
} => Block::Leaf(LinkDefinition {
|
} => Block::Leaf(LinkDefinition {
|
||||||
|
@ -2336,11 +2338,11 @@ mod test {
|
||||||
fn parse_div() {
|
fn parse_div() {
|
||||||
test_parse!(
|
test_parse!(
|
||||||
concat!("::: cls\n", "abc\n", ":::\n",),
|
concat!("::: cls\n", "abc\n", ":::\n",),
|
||||||
(Enter(Container(Div)), "cls"),
|
(Enter(Container(Div { class: "cls" })), "cls"),
|
||||||
(Enter(Leaf(Paragraph)), ""),
|
(Enter(Leaf(Paragraph)), ""),
|
||||||
(Inline, "abc"),
|
(Inline, "abc"),
|
||||||
(Exit(Leaf(Paragraph)), ""),
|
(Exit(Leaf(Paragraph)), ""),
|
||||||
(Exit(Container(Div)), "cls"),
|
(Exit(Container(Div { class: "cls" })), "cls"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2348,11 +2350,11 @@ mod test {
|
||||||
fn parse_div_no_class() {
|
fn parse_div_no_class() {
|
||||||
test_parse!(
|
test_parse!(
|
||||||
concat!(":::\n", "abc\n", ":::\n",),
|
concat!(":::\n", "abc\n", ":::\n",),
|
||||||
(Enter(Container(Div)), ""),
|
(Enter(Container(Div { class: "" })), ""),
|
||||||
(Enter(Leaf(Paragraph)), ""),
|
(Enter(Leaf(Paragraph)), ""),
|
||||||
(Inline, "abc"),
|
(Inline, "abc"),
|
||||||
(Exit(Leaf(Paragraph)), ""),
|
(Exit(Leaf(Paragraph)), ""),
|
||||||
(Exit(Container(Div)), ""),
|
(Exit(Container(Div { class: "" })), ""),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -917,7 +917,7 @@ impl<'s> Parser<'s> {
|
||||||
}
|
}
|
||||||
block::Node::Container(c) => match c {
|
block::Node::Container(c) => match c {
|
||||||
block::Container::Blockquote => Container::Blockquote,
|
block::Container::Blockquote => Container::Blockquote,
|
||||||
block::Container::Div => Container::Div { class: content },
|
block::Container::Div { class } => Container::Div { class },
|
||||||
block::Container::Footnote { label } => Container::Footnote { label },
|
block::Container::Footnote { label } => Container::Footnote { label },
|
||||||
block::Container::List {
|
block::Container::List {
|
||||||
kind: block::ListKind { ty, tight },
|
kind: block::ListKind { ty, tight },
|
||||||
|
|
Loading…
Reference in a new issue