Skip to content

Commit

Permalink
docs(readme): add fixable information
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed May 4, 2016
1 parent c807d83 commit 37ad635
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
14 changes: 13 additions & 1 deletion README.md
@@ -1,6 +1,11 @@
# textlint-rule-no-nfd [![textlint rule](https://img.shields.io/badge/textlint-fixable-green.svg?style=social)](https://textlint.github.io/)

textlint rule that disallow to use NFD like UTF8-MAC 濁点.
[textlint](https://textlint.github.io/ "textlint") rule that disallow to use NFD like UTF8-MAC 濁点.

> ホ゜ケット
> エンシ゛ン
といったMac OS XでPDFやFinderからのコピペで問題となる濁点を見つけて、修正する[textlint](https://textlint.github.io/ "textlint")ルールです。

## Install

Expand All @@ -27,6 +32,13 @@ Via CLI
textlint --rule no-nfd README.md
```

## Fixable

[![textlint rule](https://img.shields.io/badge/textlint-fixable-green.svg?style=social)](https://textlint.github.io/)

`textlint --fix` での[自動修正](https://github.com/textlint/textlint/blob/master/docs/rule-fixer.md)に対応しています。


## Example

゜or `\u309a`
Expand Down
4 changes: 2 additions & 2 deletions src/textlint-rule-no-nfd.js
Expand Up @@ -18,9 +18,9 @@ function reporter(context) {
}
// \u309b\u309c => \u309a\u3099
const dakutenChars = text.slice(index - 1, index + 1);
const nfdlized = dakutenChars.replace("\u309B", "\u3099").replace("\u309C", "\u309A")
const nfdlized = dakutenChars.replace("\u309B", "\u3099").replace("\u309C", "\u309A");
const expectedText = unorm.nfc(nfdlized);
const ruleError = new RuleError(`Disallow to use NFD(well-known as Mac濁点): "${dakutenChars}" => "${expectedText}"`, {
const ruleError = new RuleError(`Disallow to use NFD(well-known as UTF8-MAC 濁点): "${dakutenChars}" => "${expectedText}"`, {
index,
fix: fixer.replaceTextRange([index - 1, index + 1], expectedText)
});
Expand Down
8 changes: 4 additions & 4 deletions test/textlint-rule-no-nfd-test.js
Expand Up @@ -16,7 +16,7 @@ tester.run("no-todo", rule, {
output: "ポケット",
errors: [
{
message: `Disallow to use NFD(well-known as Mac濁点): "ホ\u309a" => "ポ"`,
message: `Disallow to use NFD(well-known as UTF8-MAC 濁点): "ホ\u309a" => "ポ"`,
line: 1,
column: 2
}
Expand All @@ -27,7 +27,7 @@ tester.run("no-todo", rule, {
output: "ポケット",
errors: [
{
message: `Disallow to use NFD(well-known as Mac濁点): "ホ\u309c" => "ポ"`,
message: `Disallow to use NFD(well-known as UTF8-MAC 濁点): "ホ\u309c" => "ポ"`,
line: 1,
column: 2
}
Expand All @@ -38,7 +38,7 @@ tester.run("no-todo", rule, {
output:"エンジン",
errors: [
{
message: `Disallow to use NFD(well-known as Mac濁点): "シ\u3099" => "ジ"`,
message: `Disallow to use NFD(well-known as UTF8-MAC 濁点): "シ\u3099" => "ジ"`,
line: 1,
column: 4
}
Expand All @@ -50,7 +50,7 @@ tester.run("no-todo", rule, {
output:"エンジン",
errors: [
{
message: `Disallow to use NFD(well-known as Mac濁点): "シ\u309b" => "ジ"`,
message: `Disallow to use NFD(well-known as UTF8-MAC 濁点): "シ\u309b" => "ジ"`,
line: 1,
column: 4
}
Expand Down

0 comments on commit 37ad635

Please sign in to comment.