Apply more suggestions.
This commit is contained in:
@@ -71,7 +71,7 @@ where
|
||||
alt((space1, line_ending, eof)),
|
||||
)),
|
||||
|(_start, (indent_level, _), (_bullet_type, bull), _after_whitespace)| {
|
||||
!Into::<&str>::into(bull).starts_with("*") || *indent_level > 0
|
||||
!Into::<&str>::into(bull).starts_with('*') || *indent_level > 0
|
||||
},
|
||||
)(remaining)
|
||||
.is_ok()
|
||||
@@ -79,7 +79,7 @@ where
|
||||
return Ok((input, ()));
|
||||
}
|
||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||
"No element detected.".into(),
|
||||
"No element detected.",
|
||||
))));
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ where
|
||||
Some(final_child) => final_child,
|
||||
None => {
|
||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||
"Plain lists require at least one element.".into(),
|
||||
"Plain lists require at least one element.",
|
||||
))));
|
||||
}
|
||||
};
|
||||
@@ -192,7 +192,7 @@ fn plain_list_item<'b, 'g, 'r, 's>(
|
||||
let (remaining, (indent_level, _leading_whitespace)) = indentation_level(context, input)?;
|
||||
let (remaining, (bullet_type, bull)) = verify(
|
||||
parser_with_context!(bullet)(context),
|
||||
|(_bullet_type, bull)| !Into::<&str>::into(bull).starts_with("*") || indent_level > 0,
|
||||
|(_bullet_type, bull)| !Into::<&str>::into(bull).starts_with('*') || indent_level > 0,
|
||||
)(remaining)?;
|
||||
|
||||
let (remaining, maybe_counter_set) =
|
||||
@@ -227,35 +227,32 @@ fn plain_list_item<'b, 'g, 'r, 's>(
|
||||
let maybe_contentless_item: Res<OrgSource<'_>, ()> = peek(parser_with_context!(
|
||||
detect_contentless_item_contents
|
||||
)(&parser_context))(remaining);
|
||||
match maybe_contentless_item {
|
||||
Ok((_rem, _ws)) => {
|
||||
let (remaining, _trailing_ws) = if context.should_consume_trailing_whitespace() {
|
||||
recognize(alt((recognize(many1(blank_line)), eof)))(remaining)?
|
||||
} else {
|
||||
recognize(alt((blank_line, eof)))(remaining)?
|
||||
};
|
||||
let source = get_consumed(input, remaining);
|
||||
return Ok((
|
||||
remaining,
|
||||
(
|
||||
list_type,
|
||||
PlainListItem {
|
||||
source: source.into(),
|
||||
indentation: indent_level,
|
||||
bullet: bull.into(),
|
||||
counter: maybe_counter_set,
|
||||
checkbox: None,
|
||||
tag: maybe_tag
|
||||
.map(|(_ws, item_tag)| item_tag)
|
||||
.unwrap_or(Vec::new()),
|
||||
pre_blank: 0,
|
||||
children: Vec::new(),
|
||||
},
|
||||
),
|
||||
));
|
||||
}
|
||||
Err(_) => {}
|
||||
};
|
||||
if let Ok((_rem, _ws)) = maybe_contentless_item {
|
||||
let (remaining, _trailing_ws) = if context.should_consume_trailing_whitespace() {
|
||||
recognize(alt((recognize(many1(blank_line)), eof)))(remaining)?
|
||||
} else {
|
||||
recognize(alt((blank_line, eof)))(remaining)?
|
||||
};
|
||||
let source = get_consumed(input, remaining);
|
||||
return Ok((
|
||||
remaining,
|
||||
(
|
||||
list_type,
|
||||
PlainListItem {
|
||||
source: source.into(),
|
||||
indentation: indent_level,
|
||||
bullet: bull.into(),
|
||||
counter: maybe_counter_set,
|
||||
checkbox: None,
|
||||
tag: maybe_tag
|
||||
.map(|(_ws, item_tag)| item_tag)
|
||||
.unwrap_or(Vec::new()),
|
||||
pre_blank: 0,
|
||||
children: Vec::new(),
|
||||
},
|
||||
),
|
||||
));
|
||||
}
|
||||
let (remaining, pre_blank) = item_tag_post_gap(&parser_context, remaining)?;
|
||||
let pre_blank = Into::<&str>::into(pre_blank)
|
||||
.bytes()
|
||||
|
||||
Reference in New Issue
Block a user