Apply more suggestions.

This commit is contained in:
Tom Alexander
2023-10-16 17:28:28 -04:00
parent b4f9a3b9b6
commit 1d329cc310
8 changed files with 43 additions and 45 deletions

View File

@@ -114,18 +114,15 @@ impl<'x> RematchObject<'x> for PlainText<'x> {
recognize(one_of::<&str, &str, CustomError<_>>(" \t")),
line_ending,
))))(goal);
match is_whitespace {
Ok((new_goal, _)) => {
let (new_remaining, _) = many1(org_space_or_line_ending)(remaining)?;
remaining = new_remaining;
goal = new_goal;
continue;
}
Err(_) => {}
};
if let Ok((new_goal, _)) = is_whitespace {
let (new_remaining, _) = many1(org_space_or_line_ending)(remaining)?;
remaining = new_remaining;
goal = new_goal;
continue;
}
return Err(nom::Err::Error(CustomError::MyError(MyError(
"Target does not match.".into(),
"Target does not match.",
))));
}
@@ -144,6 +141,7 @@ mod tests {
use nom::combinator::map;
use super::*;
use crate::context::bind_context;
use crate::context::Context;
use crate::context::ContextElement;
use crate::context::GlobalSettings;
@@ -158,8 +156,9 @@ mod tests {
let initial_context = ContextElement::document_context();
let initial_context = Context::new(&global_settings, List::new(&initial_context));
let (remaining, result) = map(
parser_with_context!(plain_text(detect_standard_set_object_sans_plain_text))(
&initial_context,
bind_context!(
plain_text(detect_standard_set_object_sans_plain_text),
&initial_context
),
Object::PlainText,
)(input)