diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-07-11 19:49:34 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-07-11 19:49:34 +0200 |
commit | 2ce19d9fd8f75ee1e3d62762e91f5d18303d4d6b (patch) | |
tree | ad2aa2dc2c96b9de278f6fd5252f1b511c1e07a4 /src/construct/partial_non_lazy_continuation.rs | |
parent | b7bd2b734fae09c40d738fcd57d5ee6876f0f504 (diff) | |
download | markdown-rs-2ce19d9fd8f75ee1e3d62762e91f5d18303d4d6b.tar.gz markdown-rs-2ce19d9fd8f75ee1e3d62762e91f5d18303d4d6b.tar.bz2 markdown-rs-2ce19d9fd8f75ee1e3d62762e91f5d18303d4d6b.zip |
Add support for lazy lines
Diffstat (limited to 'src/construct/partial_non_lazy_continuation.rs')
-rw-r--r-- | src/construct/partial_non_lazy_continuation.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/construct/partial_non_lazy_continuation.rs b/src/construct/partial_non_lazy_continuation.rs new file mode 100644 index 0000000..7964de3 --- /dev/null +++ b/src/construct/partial_non_lazy_continuation.rs @@ -0,0 +1,26 @@ +//! To do. + +use crate::token::Token; +use crate::tokenizer::{Code, State, StateFnResult, Tokenizer}; + +/// To do. +pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { + match code { + Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => { + tokenizer.enter(Token::LineEnding); + tokenizer.consume(code); + tokenizer.exit(Token::LineEnding); + (State::Fn(Box::new(non_lazy_after)), None) + } + _ => (State::Nok, None), + } +} + +/// To do. +fn non_lazy_after(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { + if tokenizer.lazy { + (State::Nok, None) + } else { + (State::Ok, Some(vec![code])) + } +} |