Break up 'types' module
This commit is contained in:
parent
c6f9ea667d
commit
db8c02df04
36 changed files with 382 additions and 329 deletions
|
|
@ -1,9 +1,7 @@
|
|||
use crate::{
|
||||
prelude::*,
|
||||
syntax::content::parser::{
|
||||
context::Inline, lexeme::Lexeme, state::State, token::Token,
|
||||
},
|
||||
types::Graph,
|
||||
syntax::content::parser::{context::Inline, Lexeme, State, Token},
|
||||
graph::Graph,
|
||||
};
|
||||
|
||||
/// Handles open anchor contexts until an anchor token is fully parsed.
|
||||
|
|
@ -154,7 +152,7 @@ fn push(
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{syntax::content::parser, types::Graph};
|
||||
use crate::{syntax::content::parser, graph::Graph};
|
||||
|
||||
fn read(input: &str) -> String {
|
||||
parser::read(input, &Graph::default())
|
||||
|
|
|
|||
|
|
@ -5,16 +5,11 @@ use crate::{
|
|||
syntax::content::{
|
||||
Parseable as _,
|
||||
parser::{
|
||||
Block,
|
||||
lexeme::Lexeme,
|
||||
state::State,
|
||||
token::{
|
||||
Token, header::Header, list::List, literal::Literal,
|
||||
paragraph::Paragraph, preformat::PreFormat,
|
||||
},
|
||||
Block, Token, Lexeme, State,
|
||||
token::{Header, List, Literal, Paragraph, PreFormat},
|
||||
},
|
||||
},
|
||||
types::Graph,
|
||||
graph::Graph,
|
||||
};
|
||||
|
||||
pub fn parse(
|
||||
|
|
@ -91,14 +86,10 @@ mod tests {
|
|||
|
||||
use crate::{
|
||||
syntax::content::parser::{
|
||||
self, Block, Token, context,
|
||||
state::State,
|
||||
token::{
|
||||
header::{Header, Level},
|
||||
preformat::PreFormat,
|
||||
},
|
||||
self, Block, Token, context, State,
|
||||
token::{Header, header::Level, PreFormat},
|
||||
},
|
||||
types::Graph,
|
||||
graph::Graph,
|
||||
};
|
||||
|
||||
fn read(input: &str) -> String {
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ use crate::{
|
|||
syntax::content::{
|
||||
Parseable as _,
|
||||
parser::{
|
||||
Inline, context,
|
||||
lexeme::Lexeme,
|
||||
state::{AnchorBuffer, State},
|
||||
token::{Token, anchor::Anchor, code::Code, literal::Literal},
|
||||
Lexeme, State,
|
||||
state::AnchorBuffer,
|
||||
Inline, context, Token,
|
||||
token::{Anchor, Code, Literal},
|
||||
},
|
||||
},
|
||||
types::Graph,
|
||||
graph::Graph,
|
||||
};
|
||||
|
||||
pub fn parse(
|
||||
|
|
|
|||
|
|
@ -3,13 +3,9 @@ use std::{iter::Peekable, slice::Iter};
|
|||
use crate::{
|
||||
prelude::*,
|
||||
syntax::content::parser::{
|
||||
context::Block,
|
||||
lexeme::Lexeme,
|
||||
nest,
|
||||
state::{ListBuffer, State},
|
||||
token::{Token, item::Item},
|
||||
context::Block, Token, Lexeme, State, state, token::Item, format,
|
||||
},
|
||||
types::Graph,
|
||||
graph::Graph,
|
||||
};
|
||||
|
||||
/// Handles open list contexts until a list is fully parsed.
|
||||
|
|
@ -52,7 +48,7 @@ pub fn parse(
|
|||
}
|
||||
if item_candidate.depth.is_some() {
|
||||
// if the current item candidate has a known depth, push it
|
||||
item_candidate.text = nest(&item_candidate.text, graph);
|
||||
item_candidate.text = format(&item_candidate.text, graph);
|
||||
candidate.items.push(item_candidate.clone());
|
||||
}
|
||||
// push list candidate, reset state and exit context
|
||||
|
|
@ -60,11 +56,11 @@ pub fn parse(
|
|||
tokens.push(Token::List(candidate.clone()));
|
||||
state.context.block = Block::None;
|
||||
iterator.next();
|
||||
*buffer = ListBuffer::default();
|
||||
*buffer = state::ListBuffer::default();
|
||||
} else if lexeme.match_char('\n') {
|
||||
// found end of item, push it and reset state
|
||||
log!("Accepting item candidate {item_candidate}");
|
||||
item_candidate.text = nest(&item_candidate.text, graph);
|
||||
item_candidate.text = format(&item_candidate.text, graph);
|
||||
candidate.items.push(item_candidate.clone());
|
||||
*item_candidate = Item::default();
|
||||
buffer.depth = 0;
|
||||
|
|
@ -86,10 +82,8 @@ pub fn parse(
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
syntax::content::parser::{
|
||||
self, context::list::parse, lexeme::Lexeme, state::State,
|
||||
},
|
||||
types::Graph,
|
||||
syntax::content::parser::{self, context::list::parse, Lexeme, State},
|
||||
graph::Graph,
|
||||
};
|
||||
|
||||
fn read(input: &str) -> String {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue