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/code_indented.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/code_indented.rs')
-rw-r--r-- | src/construct/code_indented.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/construct/code_indented.rs b/src/construct/code_indented.rs index 8966249..74a0938 100644 --- a/src/construct/code_indented.rs +++ b/src/construct/code_indented.rs @@ -128,17 +128,20 @@ fn after(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { /// cd /// ``` fn further_start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { - // To do: `nok` if lazy line. - match code { - Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => { - tokenizer.enter(Token::LineEnding); - tokenizer.consume(code); - tokenizer.exit(Token::LineEnding); - (State::Fn(Box::new(further_start)), None) + if tokenizer.lazy { + (State::Nok, None) + } else { + match code { + Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => { + tokenizer.enter(Token::LineEnding); + tokenizer.consume(code); + tokenizer.exit(Token::LineEnding); + (State::Fn(Box::new(further_start)), None) + } + _ => tokenizer.attempt(space_or_tab_min_max(TAB_SIZE, TAB_SIZE), |ok| { + Box::new(if ok { further_end } else { further_begin }) + })(tokenizer, code), } - _ => tokenizer.attempt(space_or_tab_min_max(TAB_SIZE, TAB_SIZE), |ok| { - Box::new(if ok { further_end } else { further_begin }) - })(tokenizer, code), } } |