-
Notifications
You must be signed in to change notification settings - Fork 939
Closed
Description
Discussed in #4451
Originally posted by maayanalgresie July 3, 2025
Hi,
In the examples, I see that the markdown supports mentions of the type @FIRST or @first-second, but I need to mention full names that include spaces (e.g., @FIRST Last).
Is there a markdown format that supports mentions with spaces in the display name?
Or would I need to implement a custom parsing rule to handle this?
Thanks!
[placeholder](type:value) is a good pattern, for example Cursor mdc links uses that: [component.tsx](mdc:src/components/example/component.tsx)
@[zbeyens](https://github.com/zbeyens)
zbeyens
[yesterday](https://github.com/udecode/plate/discussions/4451#discussioncomment-13673676)
Maintainer
Here's the regex for parsing text format:
// Basic regex
const mentionRegex = /\[([^\]]+)\]\(mention:([^)]+)\)/g;
// With capture groups:
// $1 = display text
// $2 = mention id
// Example usage:
const text = "Hello [John Doe](mention:user_123), check [Button.tsx](mention:file_abc)";
// Parse all mentions
const mentions = Array.from(text.matchAll(mentionRegex)).map(match => ({
fullMatch: match[0],
displayText: match[1],
id: match[2],
index: match.index
}));
// Replace mentions with custom rendering
const rendered = text.replace(mentionRegex, (match, displayText, id) => {
if (id.startsWith('user_')) {
return `<span class="mention-user">@${displayText}</span>`;
}
if (id.startsWith('file_')) {
return `<span class="mention-file">${displayText}</span>`;
}
return displayText;
});
Metadata
Metadata
Assignees
Labels
No labels