diff --git a/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts b/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts index 34648991ba35..4270be601ffa 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. 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. Numbers here. 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..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?:(?:::|[^:\n])+:/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.