Skip to content

Commit

Permalink
fix: Strがユーザーに書かれたものをかの判定に
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed May 24, 2021
1 parent 82a4eb4 commit 9f2e9c5
Show file tree
Hide file tree
Showing 9 changed files with 1,233 additions and 954 deletions.
5 changes: 5 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": [
"textlint-scripts/register"
]
}
4 changes: 4 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

`npm run-script textlint`が定義されているので次のようにすれば、この`README.md`ファイルをtextlint出来ます。

これは問題です。



```
npm install
npm run textlint -- README.md
Expand Down
6 changes: 3 additions & 3 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
"scripts": {
"textlint": "textlint",
"textlint:fix": "textlint --fix ../README.md",
"test": "npm run textlint -- -f pretty-error ../README.md",
"test": "npm run textlint -- -f pretty-error ./README.md",
"website": "textlint-website-generator --output-dir dist"
},
"author": "azu",
"license": "MIT",
"devDependencies": {
"@textlint/website-generator": "^0.11.3",
"textlint": "^11.4.0"
"textlint": "^12.0.0-beta.2"
},
"dependencies": {
"textlint-rule-preset-jtf-style": "file:.."
}
}
}
656 changes: 424 additions & 232 deletions example/yarn.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
"devDependencies": {
"glob": "^7.1.4",
"lint-staged": "^11.0.0",
"prettier": "^2.2.1",
"textlint-scripts": "^3.0.0"
"prettier": "^2.3.0",
"textlint-scripts": "^12.0.1",
"textlint-tester": "^12.0.0"
},
"dependencies": {
"analyze-desumasu-dearu": "^2.1.2",
Expand Down
7 changes: 7 additions & 0 deletions src/util/node-util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// LICENSE : MIT
"use strict";
import { RuleHelper } from "textlint-rule-helper";

/**
* ユーザーが書いたと推測されるNodeかどうかを判定する
* ユーザーが管理できないテキストは対象外としたいため。
Expand All @@ -11,5 +12,11 @@ import { RuleHelper } from "textlint-rule-helper";
export function isUserWrittenNode(node, context) {
let helper = new RuleHelper(context);
let Syntax = context.Syntax;
// Strがユーザーに書かれたと断定できるNodeかを判定する
// LinkやStrongなどはユーザーが書いていない可能性があるStrなので除外する
if (node.type === Syntax.Str) {
return helper.isPlainStrNode(node);
}
// ブロック要素の互換性のため古い除外ルールも残す
return !helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis]);
}
2 changes: 1 addition & 1 deletion test/2.1.8-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tester.run("2.1.8.算用数字", rule, {
valid: [
"1,000円",
"100 + 100 = 200",
"_200_円" // Strではない
"*200*円" // Strではない
],
invalid: [
{
Expand Down
1 change: 0 additions & 1 deletion test/mocha.opts

This file was deleted.

1,501 changes: 786 additions & 715 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit 9f2e9c5

Please sign in to comment.