mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 13:24:33 +08:00
DEV: introduces prettier for es6 files
This commit is contained in:
@ -4,23 +4,23 @@ function addMention(buffer, matches, state) {
|
||||
|
||||
let type = mentionLookup && mentionLookup(username);
|
||||
|
||||
let tag = 'a';
|
||||
let className = 'mention';
|
||||
let tag = "a";
|
||||
let className = "mention";
|
||||
let href = null;
|
||||
|
||||
if (type === 'user') {
|
||||
href = getURL('/u/') + username.toLowerCase();
|
||||
} else if (type === 'group') {
|
||||
href = getURL('/groups/') + username;
|
||||
className = 'mention-group';
|
||||
if (type === "user") {
|
||||
href = getURL("/u/") + username.toLowerCase();
|
||||
} else if (type === "group") {
|
||||
href = getURL("/groups/") + username;
|
||||
className = "mention-group";
|
||||
} else {
|
||||
tag = 'span';
|
||||
tag = "span";
|
||||
}
|
||||
|
||||
let token = new state.Token('mention_open', tag, 1);
|
||||
token.attrs = [['class', className]];
|
||||
let token = new state.Token("mention_open", tag, 1);
|
||||
token.attrs = [["class", className]];
|
||||
if (href) {
|
||||
token.attrs.push(['href', href]);
|
||||
token.attrs.push(["href", href]);
|
||||
}
|
||||
|
||||
buffer.push(token);
|
||||
@ -28,12 +28,12 @@ function addMention(buffer, matches, state) {
|
||||
username = formatUsername(username);
|
||||
}
|
||||
|
||||
token = new state.Token('text', '', 0);
|
||||
token.content = '@'+username;
|
||||
token = new state.Token("text", "", 0);
|
||||
token.content = "@" + username;
|
||||
|
||||
buffer.push(token);
|
||||
|
||||
token = new state.Token('mention_close', tag, -1);
|
||||
token = new state.Token("mention_close", tag, -1);
|
||||
buffer.push(token);
|
||||
}
|
||||
|
||||
@ -43,12 +43,11 @@ export function setup(helper) {
|
||||
});
|
||||
|
||||
helper.registerPlugin(md => {
|
||||
|
||||
const rule = {
|
||||
matcher: /@(\w[\w.-]{0,58}\w)|@(\w)/,
|
||||
onMatch: addMention
|
||||
};
|
||||
|
||||
md.core.textPostProcess.ruler.push('mentions', rule);
|
||||
md.core.textPostProcess.ruler.push("mentions", rule);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user