Make the end check work with multiple block names using allocation.
This commit is contained in:
parent
f3393417bb
commit
86e0833033
@ -42,7 +42,7 @@ pub fn lesser_block<'r, 's>(
|
||||
|
||||
let (remaining, parameters) = opt(tuple((space1, data)))(remaining)?;
|
||||
let (remaining, _nl) = line_ending(remaining)?;
|
||||
let lesser_block_end_specialized = lesser_block_end("comment");
|
||||
let lesser_block_end_specialized = lesser_block_end(name);
|
||||
let parser_context = context
|
||||
.with_additional_node(ContextElement::ConsumeTrailingWhitespace(true))
|
||||
.with_additional_node(ContextElement::Context("lesser block"))
|
||||
@ -93,13 +93,16 @@ fn data<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
||||
is_not("\r\n")(input)
|
||||
}
|
||||
|
||||
fn lesser_block_end<'x>(current_name: &'x str) -> impl for<'r, 's> Fn(Context<'r, 's>, &'s str) -> Res<&'s str, &'s str> + 'x {
|
||||
fn lesser_block_end(
|
||||
current_name: &str,
|
||||
) -> impl for<'r, 's> Fn(Context<'r, 's>, &'s str) -> Res<&'s str, &'s str> {
|
||||
let current_name_lower = current_name.to_lowercase();
|
||||
move |context: Context, input: &str| {
|
||||
start_of_line(context, input)?;
|
||||
let (remaining, _leading_whitespace) = space0(input)?;
|
||||
let (remaining, (_begin, _name, _ws)) = tuple((
|
||||
tag_no_case("#+end_"),
|
||||
tag_no_case(current_name),
|
||||
tag_no_case(current_name_lower.as_str()),
|
||||
alt((eof, line_ending)),
|
||||
))(remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
|
Loading…
x
Reference in New Issue
Block a user