MMM: Correctly parse empty strings
Surely I wouldn't forget to do that, right?
This commit is contained in:
parent
64350cfcb8
commit
9c8489ced7
|
@ -718,40 +718,54 @@ impl Context {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn full<'a>(&self, input: Span<'a>) -> IResult<Span<'a>, Token> {
|
pub fn full<'a>(&self, input: Span<'a>) -> IResult<Span<'a>, Token> {
|
||||||
map(many1(self.partial(Self::full_single)), Token::Sequence)(input)
|
map(
|
||||||
|
many_till(self.partial(Self::full_single), eof).map(|v| v.0),
|
||||||
|
Token::Sequence,
|
||||||
|
)(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inline<'a>(&self, input: Span<'a>) -> IResult<Span<'a>, Token> {
|
pub fn inline<'a>(&self, input: Span<'a>) -> IResult<Span<'a>, Token> {
|
||||||
map(many1(self.partial(Self::inline_single)), Token::Sequence)(input)
|
map(
|
||||||
|
many_till(self.partial(Self::inline_single), eof).map(|v| v.0),
|
||||||
|
Token::Sequence,
|
||||||
|
)(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inline_label_safe<'a>(&self, input: Span<'a>) -> IResult<Span<'a>, Token> {
|
pub fn inline_label_safe<'a>(&self, input: Span<'a>) -> IResult<Span<'a>, Token> {
|
||||||
map(
|
map(
|
||||||
many1(self.partial(Self::inline_label_safe_single)),
|
many_till(self.partial(Self::inline_label_safe_single), eof).map(|v| v.0),
|
||||||
Token::Sequence,
|
Token::Sequence,
|
||||||
)(input)
|
)(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn inline_profile_fields<'a>(&self, input: Span<'a>) -> IResult<Span<'a>, Token> {
|
fn inline_profile_fields<'a>(&self, input: Span<'a>) -> IResult<Span<'a>, Token> {
|
||||||
map(
|
map(
|
||||||
many1(alt((
|
many_till(
|
||||||
self.partial(Self::unicode_emoji),
|
alt((
|
||||||
self.partial(Self::tag_mention),
|
self.partial(Self::unicode_emoji),
|
||||||
self.partial(Self::tag_hashtag),
|
self.partial(Self::tag_mention),
|
||||||
self.partial(Self::raw_url),
|
self.partial(Self::tag_hashtag),
|
||||||
self.partial(Self::tag_raw_text),
|
self.partial(Self::raw_url),
|
||||||
))),
|
self.partial(Self::tag_raw_text),
|
||||||
|
)),
|
||||||
|
eof,
|
||||||
|
)
|
||||||
|
.map(|v| v.0),
|
||||||
Token::Sequence,
|
Token::Sequence,
|
||||||
)(input)
|
)(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn inline_ui<'a>(&self, input: Span<'a>) -> IResult<Span<'a>, Token> {
|
fn inline_ui<'a>(&self, input: Span<'a>) -> IResult<Span<'a>, Token> {
|
||||||
map(
|
map(
|
||||||
many1(alt((
|
many_till(
|
||||||
self.partial(Self::unicode_emoji),
|
alt((
|
||||||
self.partial(Self::shortcode_emoji),
|
self.partial(Self::unicode_emoji),
|
||||||
self.partial(Self::tag_raw_text),
|
self.partial(Self::shortcode_emoji),
|
||||||
))),
|
self.partial(Self::tag_raw_text),
|
||||||
|
)),
|
||||||
|
eof,
|
||||||
|
)
|
||||||
|
.map(|v| v.0),
|
||||||
Token::Sequence,
|
Token::Sequence,
|
||||||
)(input)
|
)(input)
|
||||||
}
|
}
|
||||||
|
@ -1709,6 +1723,13 @@ mod test {
|
||||||
.merged()
|
.merged()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_empty() {
|
||||||
|
let ctx = Context::default();
|
||||||
|
|
||||||
|
assert_eq!(parse_full(""), Token::Sequence(vec![]));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_url_chars() {
|
fn parse_url_chars() {
|
||||||
let ctx = Context::default();
|
let ctx = Context::default();
|
||||||
|
|
Loading…
Reference in New Issue