inline: fix attrs missing for inline verbatim

closes #15
This commit is contained in:
Noah Hellman 2023-02-21 17:56:05 +01:00
parent 418bb38f82
commit a7f5b337a8

View file

@ -163,6 +163,11 @@ impl<I: Iterator<Item = char> + Clone> Parser<I> {
_ => None, _ => None,
} }
.map(|(mut kind, opener_len)| { .map(|(mut kind, opener_len)| {
let e_attr = self.events.len();
self.events.push_back(Event {
kind: EventKind::Placeholder,
span: Span::empty_at(self.span.start()),
});
let opener_event = self.events.len(); let opener_event = self.events.len();
self.events.push_back(Event { self.events.push_back(Event {
kind: EventKind::Enter(kind), kind: EventKind::Enter(kind),
@ -241,10 +246,22 @@ impl<I: Iterator<Item = char> + Clone> Parser<I> {
span: span_inner, span: span_inner,
}); });
Event { let ev = Event {
kind: EventKind::Exit(kind), kind: EventKind::Exit(kind),
span: span_outer.unwrap_or(self.span), span: span_outer.unwrap_or(self.span),
};
if let Some((non_empty, span)) = self.ahead_attributes() {
self.span = span;
if non_empty {
self.events[e_attr] = Event {
kind: EventKind::Attributes,
span,
};
} }
}
ev
}) })
} }
@ -909,6 +926,19 @@ mod test {
); );
} }
#[test]
fn verbatim_attr() {
test_parse!(
"pre `raw`{#id} post",
(Str, "pre "),
(Attributes, "{#id}"),
(Enter(Verbatim), "`"),
(Str, "raw"),
(Exit(Verbatim), "`"),
(Str, " post"),
);
}
#[test] #[test]
fn verbatim_whitespace() { fn verbatim_whitespace() {
test_parse!( test_parse!(