Apply more suggestions.

This commit is contained in:
Tom Alexander
2023-10-16 17:58:52 -04:00
parent 1d329cc310
commit 4b6c717812
14 changed files with 103 additions and 129 deletions

View File

@@ -50,24 +50,21 @@ fn _filtered_keyword<'s, F: Fn(OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s
// TODO: When key is a member of org-element-parsed-keywords, value can contain the standard set objects, excluding footnote references.
let (remaining, (consumed_input, (_, _, parsed_key, _))) =
consumed(tuple((space0, tag("#+"), key_parser, tag(":"))))(input)?;
match tuple((
if let Ok((remaining, _)) = tuple((
space0::<OrgSource<'_>, CustomError<OrgSource<'_>>>,
alt((line_ending, eof)),
))(remaining)
{
Ok((remaining, _)) => {
return Ok((
remaining,
Keyword {
source: consumed_input.into(),
affiliated_keywords: AffiliatedKeywords::default(), // To be populated by the caller if this keyword is in a context to support affiliated keywords.
key: parsed_key.into(),
value: "".into(),
},
));
}
Err(_) => {}
};
return Ok((
remaining,
Keyword {
source: consumed_input.into(),
affiliated_keywords: AffiliatedKeywords::default(), // To be populated by the caller if this keyword is in a context to support affiliated keywords.
key: parsed_key.into(),
value: "",
},
));
}
let (remaining, _ws) = space0(remaining)?;
let (remaining, parsed_value) = recognize(many_till(
anychar,
@@ -173,16 +170,13 @@ fn plain_affiliated_key<'b, 'g, 'r, 's>(
)),
|(key, _)| key,
)(input);
match result {
Ok((remaining, ent)) => {
return Ok((remaining, ent));
}
Err(_) => {}
if let Ok((remaining, ent)) = result {
return Ok((remaining, ent));
}
}
Err(nom::Err::Error(CustomError::MyError(MyError(
"NoKeywordKey".into(),
"NoKeywordKey",
))))
}
@@ -199,16 +193,13 @@ fn dual_affiliated_key<'b, 'g, 'r, 's>(
tag("]"),
peek(tag(":")),
)))(input);
match result {
Ok((remaining, ent)) => {
return Ok((remaining, ent));
}
Err(_) => {}
if let Ok((remaining, ent)) = result {
return Ok((remaining, ent));
}
}
Err(nom::Err::Error(CustomError::MyError(MyError(
"NoKeywordKey".into(),
"NoKeywordKey",
))))
}