Remove unnecessary context from some util functions.
This commit is contained in:
@@ -63,11 +63,8 @@ pub fn blank_line(input: OrgSource<'_>) -> Res<OrgSource<'_>, OrgSource<'_>> {
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn element_trailing_whitespace<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
start_of_line(context, input)?;
|
||||
pub fn element_trailing_whitespace<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
start_of_line(input)?;
|
||||
alt((eof, recognize(many0(blank_line))))(input)
|
||||
}
|
||||
|
||||
@@ -78,9 +75,7 @@ pub fn maybe_consume_trailing_whitespace_if_not_exiting<'r, 's>(
|
||||
) -> Res<OrgSource<'s>, Option<OrgSource<'s>>> {
|
||||
if context.should_consume_trailing_whitespace() && exit_matcher_parser(context, input).is_err()
|
||||
{
|
||||
Ok(opt(parser_with_context!(element_trailing_whitespace)(
|
||||
context,
|
||||
))(input)?)
|
||||
Ok(opt(element_trailing_whitespace)(input)?)
|
||||
} else {
|
||||
Ok((input, None))
|
||||
}
|
||||
@@ -92,9 +87,7 @@ pub fn maybe_consume_trailing_whitespace<'r, 's>(
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Option<OrgSource<'s>>> {
|
||||
if context.should_consume_trailing_whitespace() {
|
||||
Ok(opt(parser_with_context!(element_trailing_whitespace)(
|
||||
context,
|
||||
))(input)?)
|
||||
Ok(opt(element_trailing_whitespace)(input)?)
|
||||
} else {
|
||||
Ok((input, None))
|
||||
}
|
||||
@@ -102,10 +95,7 @@ pub fn maybe_consume_trailing_whitespace<'r, 's>(
|
||||
|
||||
/// Check that we are at the start of a line
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn start_of_line<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, ()> {
|
||||
pub fn start_of_line<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
|
||||
if input.is_at_start_of_line() {
|
||||
Ok((input, ()))
|
||||
} else {
|
||||
@@ -117,10 +107,7 @@ pub fn start_of_line<'r, 's>(
|
||||
|
||||
/// Check that we are at the start of a line
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn preceded_by_whitespace<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, ()> {
|
||||
pub fn preceded_by_whitespace<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
|
||||
let preceding_character = input.get_preceding_character();
|
||||
match preceding_character {
|
||||
Some('\n') | Some('\r') | Some(' ') | Some('\t') => {}
|
||||
|
||||
Reference in New Issue
Block a user