FEATURE: Add support for Unicode usernames and group names

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
This commit is contained in:
Gerhard Schlager
2019-04-23 12:22:47 +02:00
parent d07605d885
commit a7bc1ecbae
29 changed files with 908 additions and 193 deletions

View File

@@ -44,7 +44,7 @@ function addHashtag(buffer, matches, state) {
export function setup(helper) {
helper.registerPlugin(md => {
const rule = {
matcher: /#([\u00C0-\u1FFF\u2C00-\uD7FF\w-:]{1,101})/,
matcher: /#([\u00C0-\u1FFF\u2C00-\uD7FF\w:-]{1,101})/,
onMatch: addHashtag
};

File diff suppressed because one or more lines are too long

View File

@@ -15,9 +15,14 @@ export class TextPostProcessRuler {
this.matcherIndex = [];
let rules = this.rules.map(
r => "(" + r.rule.matcher.toString().slice(1, -1) + ")"
);
const rules = [];
const flags = new Set("g");
this.rules.forEach(r => {
const matcher = r.rule.matcher;
rules.push(`(${matcher.source})`);
matcher.flags.split("").forEach(f => flags.add(f));
});
let i;
let regexString = "";
@@ -41,7 +46,7 @@ export class TextPostProcessRuler {
last = "x".match(regex).length - 1;
}
this.matcher = new RegExp(rules.join("|"), "g");
this.matcher = new RegExp(rules.join("|"), [...flags].join(""));
return this.matcher;
}