Skip to content

Commit 98874fe

Browse files
shahmanagerslorber
andcommitted
fix(utils): support digit-prefixed emoji shortcodes in createExcerpt
Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
1 parent 5136446 commit 98874fe

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ describe('createExcerpt', () => {
177177
it('creates excerpt preserving text containing colons while removing emoji shortcodes', () => {
178178
expect(
179179
createExcerpt(
180-
'Meeting runs 10:30:45 to 11:45:00 daily :wink:. Note: install first. Tip: run the build :+1:.',
180+
'Meeting runs 10:30:45 to 11:45:00 daily :wink: with :8ball:. Note: install first. Tip: run the build :+1: and score :100:.',
181181
),
182182
).toBe(
183-
'Meeting runs 10:30:45 to 11:45:00 daily. Note: install first. Tip: run the build.',
183+
'Meeting runs 10:30:45 to 11:45:00 daily with. Note: install first. Tip: run the build and score.',
184184
);
185185
});
186186

‎packages/docusaurus-utils/src/markdownUtils.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export function createExcerpt(fileString: string): string | undefined {
218218
// Remove admonition definition.
219219
.replace(/:::.*/, '')
220220
// Remove Emoji names within colons include preceding whitespace.
221-
.replace(/\s?:(?:\+1|-1|100|[a-zA-Z][\w-]*):/g, '')
221+
.replace(/\s?:(?:\+1|-1|100|\d*[a-zA-Z][\w-]*):/g, '')
222222
// Remove custom Markdown heading id.
223223
.replace(/\{#*[\w-]+\}/, '')
224224
// Collapse whitespace left behind by the removals above.

0 commit comments

Comments
 (0)