Add unicode tests

This commit is contained in:
Matt 2020-08-19 10:55:29 +01:00
parent 13a54ec318
commit 3ab95384df
No known key found for this signature in database
GPG key ID: 2DD462FE98BF38C2
5 changed files with 87 additions and 27 deletions

View file

@ -19,7 +19,7 @@ class RemoveDiacritics extends Operation {
this.name = "Remove Diacritics";
this.module = "Default";
this.description = "Replaces accented characters with their latin character equivalent.";
this.description = "Replaces accented characters with their latin character equivalent. Accented characters are made up of Unicode combining characters, so unicode text formatting such as strikethroughs and underlines will also be removed.";
this.infoURL = "https://wikipedia.org/wiki/Diacritic";
this.inputType = "string";
this.outputType = "string";

View file

@ -46,7 +46,6 @@ class UnicodeTextFormat extends Operation {
run(input, args) {
const [underline, strikethrough] = args;
let output = input.map(char => [char]);
console.dir(output);
if (strikethrough) {
output = output.map(charFormat => {
charFormat.push(...Utils.strToUtf8ByteArray("\u0336"));
@ -59,8 +58,8 @@ class UnicodeTextFormat extends Operation {
return charFormat;
});
}
console.dir(output);
return output.flat();
// return output.flat(); - Not supported in Node 10, polyfilled
return [].concat(...output);
}
}