Skip to content

Commit

Permalink
normalize the U+FE71 character
Browse files Browse the repository at this point in the history
`ﹱ` (`U+FE71`): Arabic Tatweel With Fathatan Above
  • Loading branch information
aborazmeh committed Jul 11, 2024
1 parent 62bb023 commit 83f40dd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ function isChildNode(node: TxtNode, types: string[]) {
});
}

function normalize(text: string) {
const replaces = {
: "ـً",
};
for (const [key, value] of Object.entries(replaces)) {
const regex = new RegExp(key, "g");
text = text.replace(regex, value);
}
return text;
}

const report: TextlintRuleModule<Options> = (context, options = {}) => {
const { Syntax, RuleError, fixer, report, getSource, locator } = context;
const skip = options.skip ?? [];
Expand All @@ -43,7 +54,7 @@ const report: TextlintRuleModule<Options> = (context, options = {}) => {
}

const text = getSource(node); // Get text
const matches = text.matchAll(/ـ+/g);
const matches = normalize(text).matchAll(/ـ+/g);
const notLetter = (index: number) => /[^\p{Letter}]/u.test(text[index]);

for (const match of matches) {
Expand Down
9 changes: 9 additions & 0 deletions test/index-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,14 @@ tester.run("rule", rule, {
},
],
},
{
text: "فشﹱل",
output: "فشل",
errors: [
{
range: [2, 3],
},
],
},
],
});

0 comments on commit 83f40dd

Please sign in to comment.