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