From 9852eba403da2fb204ed49fc065be0a2db3b7ca8 Mon Sep 17 00:00:00 2001 From: Jan Lelis Date: Sun, 20 Oct 2024 22:53:28 +0200 Subject: [PATCH] Native regexes: Use native Emoji props for Emoji text presentation --- CHANGELOG.md | 1 + data/generate_constants.rb | 8 +++++--- lib/unicode/emoji/generated_native/regex.rb | 2 +- lib/unicode/emoji/generated_native/regex_basic.rb | 2 +- lib/unicode/emoji/generated_native/regex_include_text.rb | 2 +- lib/unicode/emoji/generated_native/regex_text.rb | 2 +- lib/unicode/emoji/generated_native/regex_valid.rb | 2 +- .../emoji/generated_native/regex_valid_include_text.rb | 2 +- lib/unicode/emoji/generated_native/regex_well_formed.rb | 2 +- .../generated_native/regex_well_formed_include_text.rb | 2 +- 10 files changed, 14 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a494bc0..64804b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### 3.8.0 (unreleased) +- Native regexes: Use native Emoji props for Emoji text presentation - Improve documentation and add detailed table about which regex has which features - Add specs running through `emoji-text.txt` and classify qualification statuses per regex diff --git a/data/generate_constants.rb b/data/generate_constants.rb index 34159f8..ecb7759 100644 --- a/data/generate_constants.rb +++ b/data/generate_constants.rb @@ -68,10 +68,10 @@ def pack_and_join(ords) end end -def compile(emoji_character:, emoji_modifier:, emoji_modifier_base:, emoji_component:, emoji_presentation:, picto:, picto_no_emoji:) +def compile(emoji_character:, emoji_modifier:, emoji_modifier_base:, emoji_component:, emoji_presentation:, text_presentation:, picto:, picto_no_emoji:) emoji_presentation_sequence = \ join( - pack_and_join(TEXT_PRESENTATION) + pack(EMOJI_VARIATION_SELECTOR), + text_presentation + pack(EMOJI_VARIATION_SELECTOR), emoji_presentation + "(?!" + pack(TEXT_VARIATION_SELECTOR) + ")" + pack(EMOJI_VARIATION_SELECTOR) + "?", ) @@ -83,7 +83,7 @@ def compile(emoji_character:, emoji_modifier:, emoji_modifier_base:, emoji_compo text_presentation_sequence = \ join( - pack_and_join(TEXT_PRESENTATION)+ "(?!" + join(emoji_modifier, pack(EMOJI_VARIATION_SELECTOR)) + ")" + pack(TEXT_VARIATION_SELECTOR) + "?", + text_presentation + "(?!" + join(emoji_modifier, pack(EMOJI_VARIATION_SELECTOR)) + ")" + pack(TEXT_VARIATION_SELECTOR) + "?", emoji_presentation + pack(TEXT_VARIATION_SELECTOR), ) @@ -246,6 +246,7 @@ def compile(emoji_character:, emoji_modifier:, emoji_modifier_base:, emoji_compo emoji_modifier_base: pack_and_join(EMOJI_MODIFIER_BASES), emoji_component: pack_and_join(EMOJI_COMPONENT), emoji_presentation: pack_and_join(EMOJI_PRESENTATION), + text_presentation: pack_and_join(TEXT_PRESENTATION), picto: pack_and_join(EXTENDED_PICTOGRAPHIC), picto_no_emoji: pack_and_join(EXTENDED_PICTOGRAPHIC_NO_EMOJI) ) @@ -257,6 +258,7 @@ def compile(emoji_character:, emoji_modifier:, emoji_modifier_base:, emoji_compo emoji_modifier_base: "\\p{EBase}", emoji_component: "\\p{EComp}", emoji_presentation: "\\p{EPres}", + text_presentation: "\\p{Emoji}(?