Not sure whats going on.
This commit is contained in:
parent
9545990b52
commit
775e703ade
@ -14,6 +14,7 @@ use crate::parser::util::exit_matcher_parser;
|
|||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
use crate::parser::util::regurgitate;
|
use crate::parser::util::regurgitate;
|
||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
|
use crate::parser::util::trailing_whitespace;
|
||||||
use nom::branch::alt;
|
use nom::branch::alt;
|
||||||
use nom::bytes::complete::tag;
|
use nom::bytes::complete::tag;
|
||||||
use nom::character::complete::digit1;
|
use nom::character::complete::digit1;
|
||||||
@ -38,6 +39,7 @@ pub fn plain_list<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s s
|
|||||||
}),
|
}),
|
||||||
exit_matcher,
|
exit_matcher,
|
||||||
)(remaining)?;
|
)(remaining)?;
|
||||||
|
let (remaining, _trailing_whitespace) = trailing_whitespace(remaining)?;
|
||||||
let source = get_consumed(input, remaining);
|
let source = get_consumed(input, remaining);
|
||||||
children.insert(0, first_item);
|
children.insert(0, first_item);
|
||||||
Ok((remaining, PlainList { source, children }))
|
Ok((remaining, PlainList { source, children }))
|
||||||
@ -61,8 +63,10 @@ pub fn plain_list_item<'r, 's>(
|
|||||||
let element_matcher = parser_with_context!(element)(&parser_context);
|
let element_matcher = parser_with_context!(element)(&parser_context);
|
||||||
let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context);
|
let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context);
|
||||||
let (remaining, (bull, _ws)) = tuple((bullet, space0))(remaining)?;
|
let (remaining, (bull, _ws)) = tuple((bullet, space0))(remaining)?;
|
||||||
let (remaining, (contents, _exit_contents)) =
|
let (remaining, (contents, _exit_contents)) = many_till(element_matcher, |i| {
|
||||||
many_till(element_matcher, exit_matcher)(remaining)?;
|
let with_whitespace_added_back = regurgitate(input, i);
|
||||||
|
exit_matcher(with_whitespace_added_back)
|
||||||
|
})(remaining)?;
|
||||||
let remaining = regurgitate(input, remaining);
|
let remaining = regurgitate(input, remaining);
|
||||||
let source = get_consumed(input, remaining);
|
let source = get_consumed(input, remaining);
|
||||||
|
|
||||||
|
@ -130,6 +130,7 @@ pub fn always_fail<'r, 's>(_context: Context<'r, 's>, input: &'s str) -> Res<&'s
|
|||||||
/// Walk backwards unconsuming blank lines and line endings.
|
/// Walk backwards unconsuming blank lines and line endings.
|
||||||
///
|
///
|
||||||
/// List items are a special case where the trailing blank lines do not belong to it, unlike all other elements. Rather than write that special logic into each child parser, this just walks backwards through the consumed input to unconsume trailing blank lines and line breaks.
|
/// List items are a special case where the trailing blank lines do not belong to it, unlike all other elements. Rather than write that special logic into each child parser, this just walks backwards through the consumed input to unconsume trailing blank lines and line breaks.
|
||||||
|
#[tracing::instrument(ret, level = "debug")]
|
||||||
pub fn regurgitate<'s>(input: &'s str, remaining: &'s str) -> &'s str {
|
pub fn regurgitate<'s>(input: &'s str, remaining: &'s str) -> &'s str {
|
||||||
assert!(is_slice_of(input, remaining));
|
assert!(is_slice_of(input, remaining));
|
||||||
let mut offset = remaining.as_ptr() as usize - input.as_ptr() as usize;
|
let mut offset = remaining.as_ptr() as usize - input.as_ptr() as usize;
|
||||||
|
Loading…
Reference in New Issue
Block a user