Make plain text exit condition not an exit matcher.
I think this condition needs to not exist deeper down the tree.
This commit is contained in:
parent
b2ee44ec09
commit
bc8e640574
@ -1,30 +1,30 @@
|
|||||||
|
use nom::branch::alt;
|
||||||
|
use nom::character::complete::anychar;
|
||||||
|
use nom::combinator::peek;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
|
use nom::combinator::verify;
|
||||||
|
use nom::multi::many_till;
|
||||||
|
|
||||||
use super::object::PlainText;
|
use super::object::PlainText;
|
||||||
use super::Context;
|
use super::Context;
|
||||||
use crate::error::CustomError;
|
|
||||||
use crate::error::MyError;
|
|
||||||
use crate::error::Res;
|
use crate::error::Res;
|
||||||
use crate::parser::exiting::ExitClass;
|
|
||||||
use crate::parser::object_parser::any_object_except_plain_text;
|
use crate::parser::object_parser::any_object_except_plain_text;
|
||||||
use crate::parser::parser_context::ContextElement;
|
|
||||||
use crate::parser::parser_context::ExitMatcherNode;
|
|
||||||
use crate::parser::parser_with_context::parser_with_context;
|
use crate::parser::parser_with_context::parser_with_context;
|
||||||
use crate::parser::util::text_until_exit;
|
use crate::parser::util::exit_matcher_parser;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[tracing::instrument(ret, level = "debug")]
|
||||||
pub fn plain_text<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, PlainText<'s>> {
|
pub fn plain_text<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, PlainText<'s>> {
|
||||||
if input.len() == 0 {
|
let (remaining, source) = recognize(verify(
|
||||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
many_till(
|
||||||
"Zero input length to plain_text.",
|
anychar,
|
||||||
))));
|
peek(alt((
|
||||||
}
|
parser_with_context!(exit_matcher_parser)(context),
|
||||||
let parser_context =
|
parser_with_context!(plain_text_end)(context),
|
||||||
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
))),
|
||||||
class: ExitClass::Beta,
|
),
|
||||||
exit_matcher: &plain_text_end,
|
|(children, _exit_contents)| !children.is_empty(),
|
||||||
}));
|
))(input)?;
|
||||||
let (remaining, source) = text_until_exit(&parser_context, input)?;
|
|
||||||
Ok((remaining, PlainText { source }))
|
Ok((remaining, PlainText { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user