From 7fe01abbf9710d21d1d50cd4f42364983097cf00 Mon Sep 17 00:00:00 2001 From: abhi-byte62 Date: Sun, 22 Nov 2026 16:44:51 +0530 Subject: [PATCH 1/2] fix(utils): prevent createExcerpt dropping text between colons Signed-off-by: abhi-byte62 --- .../src/__tests__/markdownUtils.test.ts | 22 +++++++++++++++++++ .../docusaurus-utils/src/markdownUtils.ts | 2 +- 2 files changed, 23 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..96b956124321 100644 --- a/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts +++ b/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts @@ -194,6 +194,28 @@ describe('createExcerpt', () => { ); }); + it('creates excerpt for content containing colons without stripping intermediate text', () => { + expect( + createExcerpt(dedent` + Meeting runs 10:30 to 11:45 daily. + `), + ).toBe('Meeting runs 10:30 to 11:45 daily.'); + + expect( + createExcerpt(dedent` + Note: install first. Tip: run the build. + `), + ).toBe('Note: install first. Tip: run the build.'); + + expect( + createExcerpt(dedent` + We have introduced three types of item types in the example in the previous section: \`doc\`, \`category\`, and \`link\`, whose usages are fairly intuitive. We will formally introduce their APIs. There's also a fourth type: \`autogenerated\`, which we will explain in detail later. + `), + ).toBe( + "We have introduced three types of item types in the example in the previous section: doc, category, and link, whose usages are fairly intuitive. We will formally introduce their APIs. There's also a fourth type: autogenerated, which we will explain in detail later.", + ); + }); + it('creates excerpt for heading specified with anchor-id syntax', () => { expect( createExcerpt(dedent` diff --git a/packages/docusaurus-utils/src/markdownUtils.ts b/packages/docusaurus-utils/src/markdownUtils.ts index 3a82a52cbb6e..6164eeedc2eb 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|[\w+-]+):/g, '') // Remove custom Markdown heading id. .replace(/\{#*[\w-]+\}/, '') // Collapse whitespace left behind by the removals above. From 5347976b80c12c53a85c699ec75d3f284f8a1dcd Mon Sep 17 00:00:00 2001 From: abhi-byte62 Date: Sun, 22 Nov 2026 17:41:18 +0530 Subject: [PATCH 2/2] fix(utils): tighten emoji shortcode matching to preserve timestamps and adjacent tokens Signed-off-by: abhi-byte62 --- .../src/__tests__/markdownUtils.test.ts | 10 ++++++++-- packages/docusaurus-utils/src/markdownUtils.ts | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts b/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts index 96b956124321..34a39e407f3b 100644 --- a/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts +++ b/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts @@ -197,9 +197,9 @@ describe('createExcerpt', () => { it('creates excerpt for content containing colons without stripping intermediate text', () => { expect( createExcerpt(dedent` - Meeting runs 10:30 to 11:45 daily. + Meeting runs 10:30:45 to 11:45:00 daily. `), - ).toBe('Meeting runs 10:30 to 11:45 daily.'); + ).toBe('Meeting runs 10:30:45 to 11:45:00 daily.'); expect( createExcerpt(dedent` @@ -214,6 +214,12 @@ describe('createExcerpt', () => { ).toBe( "We have introduced three types of item types in the example in the previous section: doc, category, and link, whose usages are fairly intuitive. We will formally introduce their APIs. There's also a fourth type: autogenerated, which we will explain in detail later.", ); + + expect( + createExcerpt(dedent` + Party :tada::sparkles: celebration! + `), + ).toBe('Party celebration!'); }); it('creates excerpt for heading specified with anchor-id syntax', () => { diff --git a/packages/docusaurus-utils/src/markdownUtils.ts b/packages/docusaurus-utils/src/markdownUtils.ts index 6164eeedc2eb..ce2517db0e48 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|[\w+-]+):/g, '') + .replace(/\s?(?