inline: do not parse attrs in verbatim

fixes #41
This commit is contained in:
Noah Hellman 2023-05-16 16:47:19 +02:00
parent 68a5a34f7b
commit c804e666ec

View file

@ -279,8 +279,8 @@ impl<'s> Parser<'s> {
self.input.reset_span(); self.input.reset_span();
if let Some(first) = self.input.eat() { if let Some(first) = self.input.eat() {
self.parse_attributes(&first) self.parse_verbatim(&first)
.or_else(|| self.parse_verbatim(&first)) .or_else(|| self.parse_attributes(&first))
.or_else(|| self.parse_autolink(&first)) .or_else(|| self.parse_autolink(&first))
.or_else(|| self.parse_symbol(&first)) .or_else(|| self.parse_symbol(&first))
.or_else(|| self.parse_footnote_reference(&first)) .or_else(|| self.parse_footnote_reference(&first))
@ -1278,6 +1278,22 @@ mod test {
); );
} }
#[test]
fn verbatim_attr_inside() {
test_parse!(
"`a{i=0}`",
(Enter(Verbatim), "`"),
(Str, "a{i=0}"),
(Exit(Verbatim), "`"),
);
test_parse!(
r"$`\sum_{i=0}^n 2^i`",
(Enter(InlineMath), "$`"),
(Str, r"\sum_{i=0}^n 2^i"),
(Exit(InlineMath), "`"),
);
}
#[test] #[test]
fn verbatim_whitespace() { fn verbatim_whitespace() {
test_parse!( test_parse!(
@ -1765,6 +1781,23 @@ mod test {
); );
} }
#[test]
fn attr_quoted() {
test_parse!(
r#"word{a="`verb`"}"#,
(
Attributes {
container: false,
attrs: 0,
},
r#"{a="`verb`"}"#,
),
(Enter(Span), ""),
(Str, "word"),
(Exit(Span), r#"{a="`verb`"}"#),
);
}
#[test] #[test]
fn attr_whitespace() { fn attr_whitespace() {
test_parse!("word {%comment%}", (Str, "word ")); test_parse!("word {%comment%}", (Str, "word "));