aboutsummaryrefslogblamecommitdiffstats
path: root/src/construct/partial_non_lazy_continuation.rs
blob: 6d5cd7aeed501caa66accb7a8483cad9675dc001 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11










                                                                            

                        
                                                    
 






                          

                                                  
                        
                                               
                                
                                              
                                                          
         
                        


     






                      
                                                  
                       
                  
            
                 

     
//! Non-lazy continuation.
//!
//! This is a tiny helper that [flow][] constructs can use to make sure that
//! the following line is not lazy.
//! For example, [html (flow)][html_flow] and code ([fenced][code_fenced],
//! [indented][code_indented]), stop when next line is lazy.
//!
//! [flow]: crate::content::flow
//! [code_fenced]: crate::construct::code_fenced
//! [code_indented]: crate::construct::code_indented
//! [html_flow]: crate::construct::html_flow

use crate::token::Token;
use crate::tokenizer::{State, StateName, Tokenizer};

/// Start of continuation.
///
/// ```markdown
/// > | * ```js
///            ^
///   | b
/// ```
pub fn start(tokenizer: &mut Tokenizer) -> State {
    match tokenizer.current {
        Some(b'\n') => {
            tokenizer.enter(Token::LineEnding);
            tokenizer.consume();
            tokenizer.exit(Token::LineEnding);
            State::Fn(StateName::NonLazyContinuationAfter)
        }
        _ => State::Nok,
    }
}

/// After line ending.
///
/// ```markdown
///   | * ```js
/// > | b
///     ^
/// ```
pub fn after(tokenizer: &mut Tokenizer) -> State {
    if tokenizer.lazy {
        State::Nok
    } else {
        State::Ok
    }
}