Shortcode emoji parsing

This commit is contained in:
Natty 2023-10-05 22:32:53 +02:00
parent 4431a3ad62
commit c45ec852dd
Signed by: natty
GPG Key ID: BF6CB659ADEE60EC
1 changed files with 14 additions and 1 deletions

View File

@ -723,7 +723,20 @@ impl Context {
))
}
fn mention<'a>(&self, input: Span<'a>) -> IResult<Span<'a>, Token<'a>> {
fn shortcode_emoji<'a>(&self, input: Span<'a>) -> IResult<Span<'a>, Token<'a>> {
// TODO: Fail when preceded by alphanumerics
let (input, _) = tag(":")(input)?;
let (input, shortcode) = map(
recognize(many1(alt((alphanumeric1, recognize(one_of("_+-")))))),
Span::into_fragment,
)(input)?;
let (input, _) = tag(":")(input)?;
let (input, _) = not(alphanumeric1)(input)?;
Ok((input, Token::ShortcodeEmoji(shortcode.into())))
}
fn tag_mention<'a>(&self, input: Span<'a>) -> IResult<Span<'a>, Token<'a>> {
// TODO: Escaping and skip when preceded by alphanumerics
let tags = one_of("@!");