Consistently log parser state changes
This commit is contained in:
parent
a9d9413d72
commit
b745b74c76
2 changed files with 10 additions and 3 deletions
|
|
@ -27,6 +27,7 @@ pub fn parse(
|
|||
match state.context.block {
|
||||
Block::None => {
|
||||
if PreFormat::probe(lexeme) {
|
||||
log!("Block Context: None -> PreFormat on {lexeme}");
|
||||
state.context.block = Block::PreFormat;
|
||||
tokens.push(Token::PreFormat(PreFormat::new(true)));
|
||||
return true;
|
||||
|
|
@ -37,6 +38,7 @@ pub fn parse(
|
|||
iterator.peek().map_or(&Lexeme::new("", ""), |l| l),
|
||||
&mut state.dom_ids,
|
||||
));
|
||||
log!("Block Context: None -> Header on {lexeme}");
|
||||
state.context.block = Block::Header(header.level());
|
||||
tokens.push(Token::Header(header));
|
||||
return true;
|
||||
|
|
@ -49,6 +51,7 @@ pub fn parse(
|
|||
Block::PreFormat => {
|
||||
if PreFormat::probe(lexeme) {
|
||||
tokens.push(Token::PreFormat(PreFormat::new(false)));
|
||||
log!("Block Context: PreFormat -> None on {lexeme}");
|
||||
state.context.block = Block::None;
|
||||
} else {
|
||||
tokens.push(Token::Literal(Literal::lex(lexeme)));
|
||||
|
|
@ -57,14 +60,15 @@ pub fn parse(
|
|||
},
|
||||
Block::Paragraph => {
|
||||
if Paragraph::probe_end(lexeme) {
|
||||
log!("Block Context: Paragraph -> None on {lexeme}");
|
||||
tokens.push(Token::Paragraph(Paragraph::new(false)));
|
||||
log!("Block Context: Paragraph -> None on {lexeme}");
|
||||
state.context.block = Block::None;
|
||||
}
|
||||
},
|
||||
Block::Header(n) => {
|
||||
if lexeme.text() == "\n" {
|
||||
tokens.push(Token::Header(Header::from_u8(n, false, None)));
|
||||
log!("Block Context: Header -> None on {lexeme}");
|
||||
state.context.block = Block::None;
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::{iter::Peekable, slice::Iter};
|
||||
|
||||
use crate::syntax::content::{
|
||||
use crate::{prelude::*,syntax::content::{
|
||||
Parseable as _,
|
||||
parser::{
|
||||
context, Inline,
|
||||
|
|
@ -8,7 +8,7 @@ use crate::syntax::content::{
|
|||
state::State,
|
||||
token::{Token, code::Code, anchor::Anchor},
|
||||
},
|
||||
};
|
||||
}};
|
||||
|
||||
pub fn parse(
|
||||
lexeme: &Lexeme,
|
||||
|
|
@ -19,10 +19,12 @@ pub fn parse(
|
|||
match state.context.inline {
|
||||
Inline::None => {
|
||||
if Code::probe(lexeme) {
|
||||
log!("Inline Context: None -> Code on {lexeme}");
|
||||
state.context.inline = Inline::Code;
|
||||
tokens.push(Token::Code(Code::new(true)));
|
||||
return true;
|
||||
} else if Anchor::probe(lexeme) {
|
||||
log!("Inline Context: None -> Anchor on {lexeme}");
|
||||
state.context.inline = Inline::Anchor;
|
||||
state.buffers.anchor.clear();
|
||||
|
||||
|
|
@ -39,6 +41,7 @@ pub fn parse(
|
|||
},
|
||||
Inline::Code => {
|
||||
if Code::probe(lexeme) {
|
||||
log!("Inline Context: Code -> None on {lexeme}");
|
||||
state.context.inline = Inline::None;
|
||||
tokens.push(Token::Code(Code::new(false)));
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue