Skip to content
Snippets Groups Projects
Commit bc2a17bb authored by Ruben Bimberg's avatar Ruben Bimberg :computer:
Browse files

Fix incorrect error display for ascii emojis

[Merge Request: !120]
parent 435a16dc
Branches
Tags
No related merge requests found
......@@ -24,15 +24,17 @@ export class CreateCommentKeywords {
);
}
static cleaningFunction(text: string): string {
static cleaningFunction(text: string, removeAsciiNamedEmojis = false): string {
// eslint-disable-next-line max-len
const regexEmoji = new RegExp('\uD918\uDD28|\ufe0f|\u200D|\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]', 'g');
const regexKatex = new RegExp('\\$[^$\\n ]+\\$|\\$\\$[^$\\n ]+\\$\\$', 'g');
const regexMarkdown = new RegExp('(?:__|[*#])|\\[(.+?)]\\((.+?)\\)', 'g');
const regexBlank = new RegExp('[\\s]{2,}', 'gu');
const regexAsciiNamedEmojis = new RegExp(':([a-z0-9_]+):', 'g');
text = text.replace(regexKatex, '');
text = text.replace(regexEmoji, '');
text = text.replace(regexMarkdown, '');
text = text.replace(regexAsciiNamedEmojis, removeAsciiNamedEmojis ? '' : '$1');
text = text.replace(regexBlank, ' ');
return text;
}
......
......@@ -56,7 +56,7 @@ export class GrammarChecker {
this.isSpellchecking = true;
this.hasSpellcheckConfidence = true;
const unfilteredText = commentBody.innerText;
const text = CreateCommentKeywords.cleaningFunction(commentBody.innerText);
const text = CreateCommentKeywords.cleaningFunction(commentBody.innerText, true);
this.checkSpellings(text).subscribe((wordsCheck) => {
if (!this.checkLanguageConfidence(wordsCheck)) {
this.hasSpellcheckConfidence = false;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment