inline: mv footnote label from span to event field
This commit is contained in:
parent
0a144574f4
commit
9676d9e5d6
2 changed files with 9 additions and 11 deletions
|
@ -12,8 +12,8 @@ use Container::*;
|
||||||
use ControlFlow::*;
|
use ControlFlow::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum Atom {
|
pub enum Atom<'s> {
|
||||||
FootnoteReference,
|
FootnoteReference { label: &'s str },
|
||||||
Symbol,
|
Symbol,
|
||||||
Softbreak,
|
Softbreak,
|
||||||
Hardbreak,
|
Hardbreak,
|
||||||
|
@ -58,7 +58,7 @@ pub enum QuoteType {
|
||||||
pub enum EventKind<'s> {
|
pub enum EventKind<'s> {
|
||||||
Enter(Container<'s>),
|
Enter(Container<'s>),
|
||||||
Exit(Container<'s>),
|
Exit(Container<'s>),
|
||||||
Atom(Atom),
|
Atom(Atom<'s>),
|
||||||
Str,
|
Str,
|
||||||
Attributes {
|
Attributes {
|
||||||
container: bool,
|
container: bool,
|
||||||
|
@ -647,10 +647,10 @@ impl<'s> Parser<'s> {
|
||||||
.sum();
|
.sum();
|
||||||
if end {
|
if end {
|
||||||
self.input.lexer = lex::Lexer::new(ahead.as_str());
|
self.input.lexer = lex::Lexer::new(ahead.as_str());
|
||||||
self.input.span = self.input.span.after(len);
|
let span_label = self.input.span.after(len);
|
||||||
self.push(EventKind::Atom(FootnoteReference));
|
let label = span_label.of(self.input.src);
|
||||||
self.input.span = self.input.span.after(1);
|
self.input.span = Span::new(self.input.span.start(), span_label.end() + 1);
|
||||||
return Some(Continue);
|
return self.push(EventKind::Atom(FootnoteReference { label }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
|
@ -1588,7 +1588,7 @@ mod test {
|
||||||
test_parse!(
|
test_parse!(
|
||||||
"text[^footnote]. more text",
|
"text[^footnote]. more text",
|
||||||
(Str, "text"),
|
(Str, "text"),
|
||||||
(Atom(FootnoteReference), "footnote"),
|
(Atom(FootnoteReference { label: "footnote" }), "[^footnote]"),
|
||||||
(Str, ". more text"),
|
(Str, ". more text"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -836,9 +836,7 @@ impl<'s> Parser<'s> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline::EventKind::Atom(a) => match a {
|
inline::EventKind::Atom(a) => match a {
|
||||||
inline::Atom::FootnoteReference => {
|
inline::Atom::FootnoteReference { label } => Event::FootnoteReference(label),
|
||||||
Event::FootnoteReference(inline.span.of(self.src))
|
|
||||||
}
|
|
||||||
inline::Atom::Symbol => Event::Symbol(inline.span.of(self.src).into()),
|
inline::Atom::Symbol => Event::Symbol(inline.span.of(self.src).into()),
|
||||||
inline::Atom::Quote { ty, left } => match (ty, left) {
|
inline::Atom::Quote { ty, left } => match (ty, left) {
|
||||||
(inline::QuoteType::Single, true) => Event::LeftSingleQuote,
|
(inline::QuoteType::Single, true) => Event::LeftSingleQuote,
|
||||||
|
|
Loading…
Reference in a new issue