implement symbols

e.g. :some-sym:
This commit is contained in:
Noah Hellman 2023-02-04 17:10:38 +01:00
parent 61f0d6281e
commit 0420aad0a5
4 changed files with 51 additions and 0 deletions

View file

@ -236,6 +236,8 @@ pub enum OrderedListStyle {
pub enum Atom<'s> {
/// A footnote reference.
FootnoteReference(&'s str, usize),
/// A symbol, by default rendered literally but may be treated specially.
Symbol(CowStr<'s>),
/// Left single quotation mark.
LeftSingleQuote,
/// Right double quotation mark.
@ -654,6 +656,7 @@ impl<'s> Parser<'s> {
number,
)
}
inline::Atom::Symbol => Atom::Symbol(self.inlines.src(inline.span)),
inline::Atom::Quote { ty, left } => match (ty, left) {
(inline::QuoteType::Single, true) => Atom::LeftSingleQuote,
(inline::QuoteType::Single, false) => Atom::RightSingleQuote,
@ -1088,6 +1091,18 @@ mod test {
);
}
#[test]
fn symbol() {
test_parse!(
"abc :+1: def",
Start(Paragraph, Attributes::new()),
Str("abc ".into()),
Atom(Symbol("+1".into())),
Str(" def".into()),
End(Paragraph),
);
}
#[test]
fn link_inline() {
test_parse!(