Skip to content

Commit d3ddb4a

Browse files
committed
feat(rule): VOICED SOUND MARK \u309b \u309c support
1 parent 1177f57 commit d3ddb4a

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/textlint-rule-no-nfd.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ function reporter(context) {
1212
return;
1313
}
1414
const text = getSource(node);
15-
matchCaptureGroupAll(text, /([\u309a\u3099])/g).forEach(({index}) => {
15+
matchCaptureGroupAll(text, /([\u309b\u309c\u309a\u3099])/g).forEach(({index}) => {
16+
// \u309b\u309c => \u309a\u3099
1617
const dakutenChars = text.slice(index - 1, index + 1);
17-
const expectedText = unorm.nfc(dakutenChars);
18+
const nfdlized = dakutenChars.replace("\u309B", "\u3099").replace("\u309C", "\u309A")
19+
const expectedText = unorm.nfc(nfdlized);
1820
const ruleError = new RuleError(`Disallow to use NFD(well-known as Mac濁点): "${dakutenChars}" => "${expectedText}"`, {
1921
index,
2022
fix: fixer.replaceTextRange([index - 1, index + 1], expectedText)

test/textlint-rule-no-nfd-test.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ tester.run("no-todo", rule, {
1111
"エンジン"
1212
],
1313
invalid: [
14-
// single match
1514
{
1615
text: "ホ\u309aケット",
1716
output: "ポケット",
@@ -23,6 +22,17 @@ tester.run("no-todo", rule, {
2322
}
2423
]
2524
},
25+
{
26+
text: "ホ゜ケット",
27+
output: "ポケット",
28+
errors: [
29+
{
30+
message: `Disallow to use NFD(well-known as Mac濁点): "ホ\u309c" => "ポ"`,
31+
line: 1,
32+
column: 2
33+
}
34+
]
35+
},
2636
{
2737
text: "エンシ\u3099ン",
2838
output:"エンジン",
@@ -33,6 +43,18 @@ tester.run("no-todo", rule, {
3343
column: 4
3444
}
3545
]
46+
},
47+
48+
{
49+
text: "エンシ゛ン",
50+
output:"エンジン",
51+
errors: [
52+
{
53+
message: `Disallow to use NFD(well-known as Mac濁点): "シ\u309b" => "ジ"`,
54+
line: 1,
55+
column: 4
56+
}
57+
]
3658
}
3759
]
3860
});

0 commit comments

Comments
 (0)