feat: update list node parsing
This commit is contained in:
parent
ed987d468a
commit
b7ddc0f076
10 changed files with 411 additions and 242 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use nom::{IResult, InputTake};
|
||||
use nom::{IResult, InputLength, InputTake};
|
||||
|
||||
use super::{
|
||||
combinator::{blank_lines, line_ends_iter, node, GreenElement},
|
||||
|
|
@ -8,10 +8,29 @@ use super::{
|
|||
SyntaxKind,
|
||||
};
|
||||
|
||||
/// Recognizes one paragraph
|
||||
pub fn paragraph_node(input: Input) -> IResult<Input, GreenElement, ()> {
|
||||
crate::lossless_parser!(paragraph_node_base, input)
|
||||
}
|
||||
|
||||
/// Recognizes multiple paragraphs
|
||||
pub fn paragraph_nodes(input: Input) -> Result<Vec<GreenElement>, nom::Err<()>> {
|
||||
let mut i = input;
|
||||
let mut children = vec![];
|
||||
while !i.is_empty() {
|
||||
let (input, node) = paragraph_node(i)?;
|
||||
children.push(node);
|
||||
debug_assert!(
|
||||
i.input_len() > input.input_len(),
|
||||
"{} > {}",
|
||||
i.input_len(),
|
||||
input.input_len()
|
||||
);
|
||||
i = input;
|
||||
}
|
||||
Ok(children)
|
||||
}
|
||||
|
||||
fn paragraph_node_base(input: Input) -> IResult<Input, GreenElement, ()> {
|
||||
debug_assert!(!input.is_empty());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue