Skip to content

Commit

Permalink
fix bug cause by faulty skin tone range
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-Laux committed Nov 16, 2023
1 parent 5611cb0 commit 778b4de
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/parser/is_emoji.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use nom::{
branch::alt,
bytes::{complete::tag, streaming::take_while_m_n},
bytes::complete::tag,
character::complete::{self, satisfy},
combinator::{opt, recognize},
multi::{many1, many_m_n},
Expand Down Expand Up @@ -78,14 +78,12 @@ fn emoji_core(input: &str) -> IResult<&str, &str> {
complete::char('\u{e007f}'),
))),
// Regional -> Flags
take_while_m_n(2, 2, |c| ('🇦'..='🇿').contains(&c)),
recognize(tuple((
satisfy(|c| matches!(c, '🇦'..='🇿')),
satisfy(|c| matches!(c, '🇦'..='🇿')),
))),
// standard emoji chars
recognize(satisfy(single_char_emoji_core)),
// SurrPair -> normal emojis?
// recognize(tuple((
// satisfy(|c| ('\u{d800}'..='\u{dbff}').contains(&(c as u32))),
// satisfy(|c| ('\u{dc00}'..='\u{dfff}').contains(&(c as u32))),
// ))),
// keycap
recognize(tuple((
satisfy(|c| ('\u{0023}'..='\u{0039}').contains(&c)),
Expand All @@ -105,7 +103,7 @@ fn emoji_core(input: &str) -> IResult<&str, &str> {
}

fn emoji_modifier(c: char) -> bool {
matches!(c, '🏻'..='🟿')
matches!(c, '🏻' | '🏼' | '🏽' | '🏾' | '🏿')
}

const USIZE_MAX_COMPOSITE_LEN: usize = 10;
Expand Down

0 comments on commit 778b4de

Please sign in to comment.