From 047d6edd7e771bc2410755585f504f448a7cb1b3 Mon Sep 17 00:00:00 2001 From: Arya Shah Date: Thu, 26 Nov 2026 12:33:47 +0530 Subject: [PATCH 1/2] fix(utils): preserve colons in createExcerpt while stripping emoji shortcodes Update the emoji shortcode removal regex in createExcerpt() to target valid shortcodes (including +1, -1, 100, 1234, and digit-prefixed names like :8ball:) without stripping timestamps or colon-delimited prose. Fixes #13059 --- .../src/__tests__/markdownUtils.test.ts | 10 ++++++++++ packages/docusaurus-utils/src/markdownUtils.ts | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts b/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts index 34648991ba35..479ae8fb2533 100644 --- a/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts +++ b/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts @@ -174,6 +174,16 @@ describe('createExcerpt', () => { ); }); + it('creates excerpt preserving text containing colons while removing emoji shortcodes', () => { + expect( + createExcerpt( + 'Meeting runs 10:30:45 to 11:45:00 daily :wink: with :8ball:. Note: install first. Tip: run the build :+1: and score :100:.', + ), + ).toBe( + 'Meeting runs 10:30:45 to 11:45:00 daily with. Note: install first. Tip: run the build and score.', + ); + }); + it('creates excerpt for content with imports/exports declarations, with CRLF line endings', () => { expect( createExcerpt( diff --git a/packages/docusaurus-utils/src/markdownUtils.ts b/packages/docusaurus-utils/src/markdownUtils.ts index 3a82a52cbb6e..b494a16c287e 100644 --- a/packages/docusaurus-utils/src/markdownUtils.ts +++ b/packages/docusaurus-utils/src/markdownUtils.ts @@ -218,7 +218,7 @@ export function createExcerpt(fileString: string): string | undefined { // Remove admonition definition. .replace(/:::.*/, '') // Remove Emoji names within colons include preceding whitespace. - .replace(/\s?:(?:::|[^:\n])+:/g, '') + .replace(/\s?:(?:\+1|-1|100|\d*[a-zA-Z][\w-]*):/g, '') // Remove custom Markdown heading id. .replace(/\{#*[\w-]+\}/, '') // Collapse whitespace left behind by the removals above. From 6aeceeb1303044337f805e22e60d09280972e86f Mon Sep 17 00:00:00 2001 From: Arya Shah Date: Sat, 28 Nov 2026 14:12:40 +0530 Subject: [PATCH 2/2] fix(utils): include :1234: emoji shortcode in createExcerpt regex --- packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts | 4 ++-- packages/docusaurus-utils/src/markdownUtils.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts b/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts index 479ae8fb2533..4270be601ffa 100644 --- a/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts +++ b/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts @@ -177,10 +177,10 @@ describe('createExcerpt', () => { it('creates excerpt preserving text containing colons while removing emoji shortcodes', () => { expect( createExcerpt( - 'Meeting runs 10:30:45 to 11:45:00 daily :wink: with :8ball:. Note: install first. Tip: run the build :+1: and score :100:.', + 'Meeting runs 10:30:45 to 11:45:00 daily :wink: with :8ball:. Note: install first. Numbers :1234: here. Tip: run the build :+1: and score :100:.', ), ).toBe( - 'Meeting runs 10:30:45 to 11:45:00 daily with. Note: install first. Tip: run the build and score.', + 'Meeting runs 10:30:45 to 11:45:00 daily with. Note: install first. Numbers here. Tip: run the build and score.', ); }); diff --git a/packages/docusaurus-utils/src/markdownUtils.ts b/packages/docusaurus-utils/src/markdownUtils.ts index b494a16c287e..6c104cc55dbe 100644 --- a/packages/docusaurus-utils/src/markdownUtils.ts +++ b/packages/docusaurus-utils/src/markdownUtils.ts @@ -218,7 +218,7 @@ export function createExcerpt(fileString: string): string | undefined { // Remove admonition definition. .replace(/:::.*/, '') // Remove Emoji names within colons include preceding whitespace. - .replace(/\s?:(?:\+1|-1|100|\d*[a-zA-Z][\w-]*):/g, '') + .replace(/\s?:(?:\+1|-1|100|1234|\d*[a-zA-Z][\w-]*):/g, '') // Remove custom Markdown heading id. .replace(/\{#*[\w-]+\}/, '') // Collapse whitespace left behind by the removals above.