From 5999f09a4bac23169766af68fbdc71215161c1c6 Mon Sep 17 00:00:00 2001 From: Luffy Date: Tue, 2 Sep 2025 11:46:11 +0800 Subject: [PATCH] fix: normalize slugs to NFC and remove emoji variation selector (#2597) --- docs/themes.md | 2 +- src/core/render/slugify.js | 3 ++- test/unit/render-util.test.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/themes.md b/docs/themes.md index 3f485a79e..6eb436bfd 100644 --- a/docs/themes.md +++ b/docs/themes.md @@ -288,7 +288,7 @@ Docsify provides [theme properties](#theme-properties) for simplified customizat } ``` - ?> **Theme authors**: Consider providing instructions for loading your recommended web fonts manually instead of including them in your theme using `@import`. This allows users who prefer a different font to avoid loading your recommended web font(s) unnecessarily. + > [!TIP] **Theme authors**: Consider providing instructions for loading your recommended web fonts manually instead of including them in your theme using `@import`. This allows users who prefer a different font to avoid loading your recommended web font(s) unnecessarily. 4. Advanced styling may require custom CSS declarations. This is expected, however custom CSS declarations may break when new versions of Docsify are released. When possible, leverage [theme properties](#theme-properties) instead of custom declarations or lock your [CDN](cdn) URLs to a [specific version](cdn#specific-version) to avoid potential issues when using custom CSS declarations. diff --git a/src/core/render/slugify.js b/src/core/render/slugify.js index ff910d684..d27250f65 100644 --- a/src/core/render/slugify.js +++ b/src/core/render/slugify.js @@ -12,7 +12,8 @@ export function slugify(str) { let slug = str .trim() - .normalize('NFKD') + .normalize('NFC') + .replace(/\uFE0F/g, '') .replace(/[\p{Emoji_Presentation}\p{Extended_Pictographic}]/gu, '') .replace(/[A-Z]+/g, lower) .replace(/<[^>]+>/g, '') diff --git a/test/unit/render-util.test.js b/test/unit/render-util.test.js index 3ff0c1a70..094308ea8 100644 --- a/test/unit/render-util.test.js +++ b/test/unit/render-util.test.js @@ -179,7 +179,7 @@ describe('core/render/slugify', () => { expect(nestedHtmlStrippedSlug).toBe('another-broken-example'); const emojiRemovedSlug = slugify('emoji test ⚠️🔥✅'); - expect(emojiRemovedSlug).toBe('emoji-test-️'); + expect(emojiRemovedSlug).toBe('emoji-test-'); const multiSpaceSlug = slugify('Title with multiple spaces'); expect(multiSpaceSlug).toBe('title----with---multiple-spaces');