diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-08-15 11:33:05 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-08-15 11:33:05 +0200 |
commit | 13135666fac476f3cd6f059147f496533b304097 (patch) | |
tree | 527c4ffd77b7a8c3aa54b88fd41d756fe80dbf47 /src/parser.rs | |
parent | 6e20c3e79d4270fafb13a63af51eaffaa45c11e1 (diff) | |
download | markdown-rs-13135666fac476f3cd6f059147f496533b304097.tar.gz markdown-rs-13135666fac476f3cd6f059147f496533b304097.tar.bz2 markdown-rs-13135666fac476f3cd6f059147f496533b304097.zip |
Refactor to move some things to `parser`
Diffstat (limited to 'src/parser.rs')
-rw-r--r-- | src/parser.rs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/parser.rs b/src/parser.rs index a8416ed..cc93021 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1,7 +1,9 @@ //! Turn a string of markdown into events. -use crate::content::document::document; use crate::event::{Event, Point}; +use crate::state::{Name as StateName, State}; +use crate::subtokenize::subtokenize; +use crate::tokenizer::Tokenizer; use crate::{Constructs, Options}; /// Info needed, in all content types, when parsing markdown. @@ -27,15 +29,28 @@ pub fn parse<'a>(value: &'a str, options: &'a Options) -> (Vec<Event>, &'a [u8]) definitions: vec![], }; - let events = document( - &mut parse_state, + let mut tokenizer = Tokenizer::new( Point { line: 1, column: 1, index: 0, vs: 0, }, + &parse_state, ); + let state = tokenizer.push( + (0, 0), + (parse_state.bytes.len(), 0), + State::Next(StateName::DocumentStart), + ); + tokenizer.flush(state, true); + + let mut events = tokenizer.events; + + parse_state.definitions = tokenizer.tokenize_state.definitions; + + while !subtokenize(&mut events, &parse_state) {} + (events, parse_state.bytes) } |