mirror of
https://github.com/foambubble/foam.git
synced 2026-01-10 06:28:12 -05:00
Fix #1536 - add support for emoji variants in tags
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { isSome } from './core';
|
||||
export const HASHTAG_REGEX =
|
||||
/(?<=^|\s)#([0-9]*[\p{L}\p{Emoji_Presentation}/_-][\p{L}\p{Emoji_Presentation}\p{N}/_-]*)/gmu;
|
||||
/(?<=^|\s)#([0-9]*[\p{L}\p{Extended_Pictographic}/_-](?:[\p{L}\p{Extended_Pictographic}\p{N}/_-]|\uFE0F|\p{Emoji_Modifier})*)/gmu;
|
||||
export const WORD_REGEX =
|
||||
/(?<=^|\s)([0-9]*[\p{L}\p{Emoji_Presentation}/_-][\p{L}\p{Emoji_Presentation}\p{N}/_-]*)/gmu;
|
||||
/(?<=^|\s)([0-9]*[\p{L}\p{Extended_Pictographic}/_-](?:[\p{L}\p{Extended_Pictographic}\p{N}/_-]|\uFE0F|\p{Emoji_Modifier})*)/gmu;
|
||||
|
||||
export const extractHashtags = (
|
||||
text: string
|
||||
|
||||
@@ -80,6 +80,28 @@ describe('hashtag extraction', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('supports emoji tags with variant selectors (issue #1536)', () => {
|
||||
expect(
|
||||
extractHashtags('#🗃️/37-Education #🔖/37/Learning #🟣HOUSE #🟠MONEY').map(
|
||||
t => t.label
|
||||
)
|
||||
).toEqual(['🗃️/37-Education', '🔖/37/Learning', '🟣HOUSE', '🟠MONEY']);
|
||||
});
|
||||
|
||||
it('supports individual emojis with variant selectors', () => {
|
||||
// Test each emoji separately to debug
|
||||
expect(extractHashtags('#🗃️').map(t => t.label)).toEqual(['🗃️']);
|
||||
expect(extractHashtags('#🔖').map(t => t.label)).toEqual(['🔖']);
|
||||
});
|
||||
|
||||
it('supports emojis that work without variant selector', () => {
|
||||
// These emojis should work with current implementation
|
||||
expect(extractHashtags('#📥 #⭐').map(t => t.label)).toEqual([
|
||||
'📥',
|
||||
'⭐',
|
||||
]);
|
||||
});
|
||||
|
||||
it('ignores hashes in plain text urls and links', () => {
|
||||
expect(
|
||||
extractHashtags(`
|
||||
|
||||
Reference in New Issue
Block a user