This commit is contained in:
Noah Hellman 2022-12-01 18:09:09 +01:00
parent 78d6d502b6
commit 6f5829f686
3 changed files with 15 additions and 10 deletions

View file

@ -14,11 +14,9 @@ pub enum Atom {
Hardbreak,
Escape,
Nbsp,
OpenMarker, // ??
Ellipsis,
ImageMarker, // ??
EmDash,
EnDash,
EmDash,
Lt,
Gt,
Ampersand,
@ -29,13 +27,12 @@ pub enum Atom {
pub enum Node {
Str,
// link
Url,
ImageSource,
LinkReference,
FootnoteReference,
// verbatim
//Url,
//ImageSource,
//LinkReference,
//FootnoteReference,
Verbatim,
RawFormat,
RawFormat { format: Span },
InlineMath,
DisplayMath,
}
@ -138,6 +135,9 @@ impl<'s> Parser<'s> {
let atom = match first.kind {
lex::Kind::Escape => Escape,
lex::Kind::Nbsp => Nbsp,
lex::Kind::Seq(lex::Sequence::Period) if first.len == 3 => Ellipsis,
lex::Kind::Seq(lex::Sequence::Hyphen) if first.len == 2 => EnDash,
lex::Kind::Seq(lex::Sequence::Hyphen) if first.len == 3 => EmDash,
lex::Kind::Sym(lex::Symbol::Lt) => Lt,
lex::Kind::Sym(lex::Symbol::Gt) => Gt,
lex::Kind::Sym(lex::Symbol::Quote2) => Quote,

View file

@ -14,8 +14,10 @@ pub(crate) struct Token {
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Kind {
Text,
Newline,
Whitespace,
Nbsp,
Hardbreak,
Escape,
Integer,
Open(Delimiter),
@ -124,6 +126,7 @@ impl<'s> Lexer<'s> {
let kind = match first {
_ if escape && first == ' ' => Nbsp,
_ if escape && first == '\n' => Hardbreak,
_ if escape => Text,
'\\' => {
@ -136,6 +139,7 @@ impl<'s> Lexer<'s> {
}
}
'\n' => Newline,
_ if first.is_whitespace() => {
self.eat_while(char::is_whitespace);
Whitespace

View file

@ -436,7 +436,8 @@ mod test {
test_parse!(
"para0\n\npara1",
Start(Paragraph, Attributes::none()),
Str("para0\n"),
Str("para0"),
Atom(Softbreak),
End(Paragraph),
Atom(Blankline),
Start(Paragraph, Attributes::none()),