block: specify footnote label in event
instead of using span
This commit is contained in:
parent
116245367a
commit
6cebdfcc0c
2 changed files with 9 additions and 7 deletions
14
src/block.rs
14
src/block.rs
|
@ -94,7 +94,7 @@ pub enum Container<'s> {
|
|||
ListItem(ListItemKind),
|
||||
|
||||
/// Span is footnote tag.
|
||||
Footnote,
|
||||
Footnote { label: &'s str },
|
||||
|
||||
/// Span is empty, before first '|' character.
|
||||
Table,
|
||||
|
@ -275,7 +275,9 @@ impl<'s> TreeParser<'s> {
|
|||
} => Block::Leaf(LinkDefinition {
|
||||
label: span.of(self.src),
|
||||
}),
|
||||
Kind::Definition { footnote: true, .. } => Block::Container(Footnote),
|
||||
Kind::Definition { footnote: true, .. } => Block::Container(Footnote {
|
||||
label: span.of(self.src),
|
||||
}),
|
||||
Kind::Blockquote => Block::Container(Blockquote),
|
||||
Kind::ListItem { ty, .. } => Block::Container(ListItem(match ty {
|
||||
ListType::Task => ListItemKind::Task {
|
||||
|
@ -1530,11 +1532,11 @@ mod test {
|
|||
fn parse_footnote() {
|
||||
test_parse!(
|
||||
"[^tag]: description\n",
|
||||
(Enter(Container(Footnote)), "tag"),
|
||||
(Enter(Container(Footnote { label: "tag" })), "tag"),
|
||||
(Enter(Leaf(Paragraph)), ""),
|
||||
(Inline, "description"),
|
||||
(Exit(Leaf(Paragraph)), ""),
|
||||
(Exit(Container(Footnote)), "tag"),
|
||||
(Exit(Container(Footnote { label: "tag" })), "tag"),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1552,12 +1554,12 @@ mod test {
|
|||
(Inline, "[^a]"),
|
||||
(Exit(Leaf(Paragraph)), ""),
|
||||
(Atom(Blankline), "\n"),
|
||||
(Enter(Container(Footnote)), "a"),
|
||||
(Enter(Container(Footnote { label: "a" })), "a"),
|
||||
(Enter(Leaf(Paragraph)), ""),
|
||||
(Inline, "note"),
|
||||
(Exit(Leaf(Paragraph)), ""),
|
||||
(Atom(Blankline), "\n"),
|
||||
(Exit(Container(Footnote)), "a"),
|
||||
(Exit(Container(Footnote { label: "a" })), "a"),
|
||||
(Enter(Leaf(Paragraph)), ""),
|
||||
(Inline, "para"),
|
||||
(Exit(Leaf(Paragraph)), ""),
|
||||
|
|
|
@ -918,7 +918,7 @@ impl<'s> Parser<'s> {
|
|||
block::Node::Container(c) => match c {
|
||||
block::Container::Blockquote => Container::Blockquote,
|
||||
block::Container::Div => Container::Div { class: content },
|
||||
block::Container::Footnote => Container::Footnote { label: content },
|
||||
block::Container::Footnote { label } => Container::Footnote { label },
|
||||
block::Container::List {
|
||||
kind: block::ListKind { ty, tight },
|
||||
marker,
|
||||
|
|
Loading…
Reference in a new issue