Apply more suggestions.
This commit is contained in:
parent
728f79b86c
commit
4ba0e3611b
@ -42,9 +42,9 @@ pub(crate) fn in_section<'b, 'g, 'r, 's, 'x>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if we are currently an immediate child of the given section type
|
/// Checks if we are currently an immediate child of the given section type
|
||||||
pub(crate) fn immediate_in_section<'b, 'g, 'r, 's, 'x>(
|
pub(crate) fn immediate_in_section(
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'_, '_, '_, '_>,
|
||||||
section_name: &'x str,
|
section_name: &str,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
for thing in context.iter() {
|
for thing in context.iter() {
|
||||||
match thing {
|
match thing {
|
||||||
@ -133,7 +133,7 @@ pub(crate) fn start_of_line<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()>
|
|||||||
Ok((input, ()))
|
Ok((input, ()))
|
||||||
} else {
|
} else {
|
||||||
Err(nom::Err::Error(CustomError::MyError(MyError(
|
Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||||
"Not at start of line".into(),
|
"Not at start of line",
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ fn _preceded_by_whitespace<'s>(
|
|||||||
.unwrap_or(allow_start_of_file)
|
.unwrap_or(allow_start_of_file)
|
||||||
{
|
{
|
||||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||||
"Must be preceded by a whitespace character.".into(),
|
"Must be preceded by a whitespace character.",
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
Ok((input, ()))
|
Ok((input, ()))
|
||||||
@ -198,9 +198,9 @@ pub(crate) fn text_until_exit<'b, 'g, 'r, 's>(
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn not_yet_implemented() -> Res<OrgSource<'static>, ()> {
|
fn not_yet_implemented() -> Res<OrgSource<'static>, ()> {
|
||||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||||
"Not implemented yet.".into(),
|
"Not implemented yet.",
|
||||||
))));
|
))))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
@ -234,29 +234,27 @@ where
|
|||||||
/// Match single space or tab.
|
/// Match single space or tab.
|
||||||
///
|
///
|
||||||
/// In org-mode syntax, spaces and tabs are often (but not always!) interchangeable.
|
/// In org-mode syntax, spaces and tabs are often (but not always!) interchangeable.
|
||||||
pub(crate) fn org_space<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, char> {
|
pub(crate) fn org_space(input: OrgSource<'_>) -> Res<OrgSource<'_>, char> {
|
||||||
one_of(" \t")(input)
|
one_of(" \t")(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Matches a single space, tab, line ending, or end of file.
|
/// Matches a single space, tab, line ending, or end of file.
|
||||||
///
|
///
|
||||||
/// In org-mode syntax there are often delimiters that could be any whitespace at all or the end of file.
|
/// In org-mode syntax there are often delimiters that could be any whitespace at all or the end of file.
|
||||||
pub(crate) fn org_space_or_line_ending<'s>(
|
pub(crate) fn org_space_or_line_ending(input: OrgSource<'_>) -> Res<OrgSource<'_>, OrgSource<'_>> {
|
||||||
input: OrgSource<'s>,
|
|
||||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
|
||||||
alt((recognize(org_space), org_line_ending))(input)
|
alt((recognize(org_space), org_line_ending))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Match a line break or the end of the file.
|
/// Match a line break or the end of the file.
|
||||||
///
|
///
|
||||||
/// In org-mode syntax, the end of the file can serve the same purpose as a line break syntactically.
|
/// In org-mode syntax, the end of the file can serve the same purpose as a line break syntactically.
|
||||||
pub(crate) fn org_line_ending<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
pub(crate) fn org_line_ending(input: OrgSource<'_>) -> Res<OrgSource<'_>, OrgSource<'_>> {
|
||||||
alt((line_ending, eof))(input)
|
alt((line_ending, eof))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Match the whitespace at the beginning of a line and give it an indentation level.
|
/// Match the whitespace at the beginning of a line and give it an indentation level.
|
||||||
pub(crate) fn indentation_level<'b, 'g, 'r, 's>(
|
pub(crate) fn indentation_level<'s>(
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'_, '_, '_, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, (IndentationLevel, OrgSource<'s>)> {
|
) -> Res<OrgSource<'s>, (IndentationLevel, OrgSource<'s>)> {
|
||||||
let (remaining, leading_whitespace) = space0(input)?;
|
let (remaining, leading_whitespace) = space0(input)?;
|
||||||
|
@ -19,7 +19,7 @@ pub struct AffiliatedKeyword<'s> {
|
|||||||
pub value: AffiliatedKeywordValue<'s>,
|
pub value: AffiliatedKeywordValue<'s>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Default)]
|
||||||
pub struct AffiliatedKeywords<'s> {
|
pub struct AffiliatedKeywords<'s> {
|
||||||
pub(crate) keywords: BTreeMap<String, AffiliatedKeywordValue<'s>>,
|
pub(crate) keywords: BTreeMap<String, AffiliatedKeywordValue<'s>>,
|
||||||
}
|
}
|
||||||
@ -27,11 +27,3 @@ pub struct AffiliatedKeywords<'s> {
|
|||||||
pub trait GetAffiliatedKeywords<'s> {
|
pub trait GetAffiliatedKeywords<'s> {
|
||||||
fn get_affiliated_keywords<'a>(&'a self) -> &'a AffiliatedKeywords<'s>;
|
fn get_affiliated_keywords<'a>(&'a self) -> &'a AffiliatedKeywords<'s>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'s> Default for AffiliatedKeywords<'s> {
|
|
||||||
fn default() -> Self {
|
|
||||||
AffiliatedKeywords {
|
|
||||||
keywords: BTreeMap::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -101,9 +101,8 @@ impl<'s> Heading<'s> {
|
|||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.flat_map(|section| section.children.iter())
|
.flat_map(|section| section.children.iter())
|
||||||
.take_while(|element| match element {
|
.take_while(|element| {
|
||||||
Element::Planning(_) | Element::PropertyDrawer(_) => true,
|
matches!(element, Element::Planning(_) | Element::PropertyDrawer(_))
|
||||||
_ => false,
|
|
||||||
})
|
})
|
||||||
.find_map(|element| match element {
|
.find_map(|element| match element {
|
||||||
Element::PropertyDrawer(property_drawer) => Some(property_drawer),
|
Element::PropertyDrawer(property_drawer) => Some(property_drawer),
|
||||||
@ -121,10 +120,8 @@ impl<'s> Document<'s> {
|
|||||||
.iter()
|
.iter()
|
||||||
.flat_map(|zeroth_section| zeroth_section.children.iter());
|
.flat_map(|zeroth_section| zeroth_section.children.iter());
|
||||||
let property_drawer = zeroth_section_children
|
let property_drawer = zeroth_section_children
|
||||||
.take_while(|element| match element {
|
.take_while(|element| {
|
||||||
Element::Comment(_) => true,
|
matches!(element, Element::Comment(_) | Element::PropertyDrawer(_))
|
||||||
Element::PropertyDrawer(_) => true,
|
|
||||||
_ => false,
|
|
||||||
})
|
})
|
||||||
.find_map(|element| match element {
|
.find_map(|element| match element {
|
||||||
Element::PropertyDrawer(property_drawer) => Some(property_drawer),
|
Element::PropertyDrawer(property_drawer) => Some(property_drawer),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user