diff --git a/src/lib/components/common/RichTextInput.svelte b/src/lib/components/common/RichTextInput.svelte index 37e4e9bdd3..61654914b2 100644 --- a/src/lib/components/common/RichTextInput.svelte +++ b/src/lib/components/common/RichTextInput.svelte @@ -499,7 +499,7 @@ const escaped = line.replace(/&/g, '&').replace(//g, '>'); // Now replace the escaped mention patterns back into real spans const withMentions = escaped.replace( - /<([@#$])([\w.\-:/]+)(?:\|([^&]*?))?>|<\/([\w.\-:/]+)\|([^&]*?)>/g, + /<([@#$])([^|&\s]+)(?:\|([^&]*?))?>|<\/([\w.\-:/]+)\|([^&]*?)>/g, (_, ch, id, label, slashSkillId, slashSkillLabel) => { const mentionChar = ch || '$'; const mentionId = id || slashSkillId; diff --git a/src/lib/utils/marked/mention-extension.ts b/src/lib/utils/marked/mention-extension.ts index 835ce30714..2932da4c7c 100644 --- a/src/lib/utils/marked/mention-extension.ts +++ b/src/lib/utils/marked/mention-extension.ts @@ -40,7 +40,7 @@ export function mentionExtension(opts: MentionOptions = {}) { // Compile the regex once when the extension is created, not on every tokenizer call. // mentionStart fires on every '<' in the document, making the tokenizer a hot path. const trigger = opts.triggerChar ?? '@'; - const re = new RegExp(`^<\\${trigger}([\\w.\\-:/]+)(?:\\|([^>]*))?>`); + const re = new RegExp(`^<\\${trigger}([^|>\\s]+)(?:\\|([^>]*))?>`); const snapshot: MentionOptions = { triggerChar: trigger, className: opts.className,