Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(emoji): Fix issue where numbers and some symbols got big_emoji class applied #1469

Merged
merged 8 commits into from
Nov 8, 2023
17 changes: 13 additions & 4 deletions kit/src/components/message/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,21 @@ fn markdown(text: &str, emojis: bool) -> String {
let txt = text.trim();

if emojis {
let r = replace_emojis(text);
if is_only_emojis(&r) {
let r = replace_emojis(txt);
// TODO: Watch this issue for a fix: https://github.com/open-i18n/rust-unic/issues/280
// This is a temporary workaround for some characters unic-emoji-char thinks are emojis
if !r.chars().all(char::is_alphanumeric) // for any numbers, eg 1, 11, 111
&& r != "#"
&& r != "*"
&& r != "##"
&& r != "**"
&& r != "-"
&& is_only_emojis(&r)
{
WanderingHogan marked this conversation as resolved.
Show resolved Hide resolved
return format!("<span class=\"big-emoji\">{r}</span>");
WanderingHogan marked this conversation as resolved.
Show resolved Hide resolved
} else if is_only_emojis(txt) || r == "-" {
return format!("<p>{txt}</p>");
WanderingHogan marked this conversation as resolved.
Show resolved Hide resolved
}
} else if is_only_emojis(txt) {
return format!("<span class=\"big-emoji\">{txt}</span>");
}

let mut options = Options::empty();
Expand Down
Loading