auto-link mentions with user names having symbols
this also handles the case where user_name having '_'
Этот коммит содержится в:
@@ -121,8 +121,11 @@ export class MattermostMarkdownRenderer extends marked.Renderer {
|
|||||||
paragraph(text) {
|
paragraph(text) {
|
||||||
let outText = text;
|
let outText = text;
|
||||||
|
|
||||||
|
// required so markdown does not strip '_' from @user_names
|
||||||
|
outText = TextFormatting.doFormatMentions(text);
|
||||||
|
|
||||||
if (!('emoticons' in this.options) || this.options.emoticon) {
|
if (!('emoticons' in this.options) || this.options.emoticon) {
|
||||||
outText = TextFormatting.doFormatEmoticons(text);
|
outText = TextFormatting.doFormatEmoticons(outText);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.formattingOptions.singleline) {
|
if (this.formattingOptions.singleline) {
|
||||||
@@ -136,7 +139,7 @@ export class MattermostMarkdownRenderer extends marked.Renderer {
|
|||||||
return `<table class="markdown__table"><thead>${header}</thead><tbody>${body}</tbody></table>`;
|
return `<table class="markdown__table"><thead>${header}</thead><tbody>${body}</tbody></table>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
text(text) {
|
text(txt) {
|
||||||
return TextFormatting.doFormatText(text, this.formattingOptions);
|
return TextFormatting.doFormatText(txt, this.formattingOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ export function doFormatText(text, options) {
|
|||||||
const tokens = new Map();
|
const tokens = new Map();
|
||||||
|
|
||||||
// replace important words and phrases with tokens
|
// replace important words and phrases with tokens
|
||||||
output = autolinkUrls(output, tokens);
|
|
||||||
output = autolinkAtMentions(output, tokens);
|
output = autolinkAtMentions(output, tokens);
|
||||||
|
output = autolinkUrls(output, tokens);
|
||||||
output = autolinkHashtags(output, tokens);
|
output = autolinkHashtags(output, tokens);
|
||||||
|
|
||||||
if (!('emoticons' in options) || options.emoticon) {
|
if (!('emoticons' in options) || options.emoticon) {
|
||||||
@@ -78,6 +78,13 @@ export function doFormatEmoticons(text) {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function doFormatMentions(text) {
|
||||||
|
const tokens = new Map();
|
||||||
|
let output = autolinkAtMentions(text, tokens);
|
||||||
|
output = replaceTokens(output, tokens);
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
export function sanitizeHtml(text) {
|
export function sanitizeHtml(text) {
|
||||||
let output = text;
|
let output = text;
|
||||||
|
|
||||||
@@ -188,6 +195,7 @@ function autolinkAtMentions(text, tokens) {
|
|||||||
|
|
||||||
let output = text;
|
let output = text;
|
||||||
output = output.replace(/(^|\s)(@([a-z0-9.\-_]*))/gi, replaceAtMentionWithToken);
|
output = output.replace(/(^|\s)(@([a-z0-9.\-_]*))/gi, replaceAtMentionWithToken);
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user