Skip to content

Commit a220d23

Browse files
committed
fix(rule): support Html node correctly
Ignore attributes of Html node on counting. fix #13 Ref https://github.com/textlint/textlint-util-to-string/releases/tag/3.0.0
1 parent 9e76fcb commit a220d23

File tree

5 files changed

+2046
-1982
lines changed

5 files changed

+2046
-1982
lines changed

package.json

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,15 @@
3232
"prettier": "prettier --write **/*.js"
3333
},
3434
"dependencies": {
35-
"sentence-splitter": "^3.0.10",
36-
"textlint-rule-helper": "^2.0.0",
37-
"textlint-util-to-string": "^2.1.1"
35+
"sentence-splitter": "^3.0.11",
36+
"textlint-rule-helper": "^2.1.1",
37+
"textlint-util-to-string": "^3.0.0"
3838
},
3939
"devDependencies": {
40-
"babel-plugin-add-module-exports": "^0.2.1",
41-
"espower-babel": "^4.0.0",
42-
"lint-staged": "^7.2.0",
43-
"power-assert": "^1.6.0",
44-
"prettier": "^1.13.7",
45-
"textlint-plugin-html": "^0.1.7",
46-
"textlint-scripts": "^1.4.2"
40+
"lint-staged": "^9.2.5",
41+
"prettier": "^1.18.2",
42+
"textlint-plugin-html": "^0.2.0",
43+
"textlint-scripts": "^2.1.0"
4744
},
4845
"email": "[email protected]",
4946
"lint-staged": {
@@ -57,4 +54,4 @@
5754
"printWidth": 120,
5855
"tabWidth": 4
5956
}
60-
}
57+
}

src/sentence-length.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// LICENSE : MIT
22
"use strict";
33
import { splitAST, Syntax as SentenceSyntax } from "sentence-splitter";
4-
import StringSource from "textlint-util-to-string";
4+
import { StringSource } from "textlint-util-to-string";
55
import { RuleHelper } from "textlint-rule-helper";
66

77
const defaultOptions = {

test/mocha.opts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--require textlint-scripts/register

test/sentence-length-test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ tester.run("textlint-rule-sentence-length", rule, {
4040
max: 5
4141
}
4242
},
43+
{
44+
// html node
45+
// == 12345
46+
text: '<s>123</s><b>45</b>',
47+
options: {
48+
max: 5
49+
}
50+
},
4351
{
4452
// List
4553
text: '- [abc](http://example.com "abc")de',
@@ -73,6 +81,13 @@ tester.run("textlint-rule-sentence-length", rule, {
7381
options: {
7482
max: 90
7583
}
84+
},
85+
// regression test
86+
// https://github.com/textlint-rule/textlint-rule-sentence-length/issues/13
87+
{
88+
text: "ではみなさんは、そういうふうに川だと云いわれたり、乳の流れたあとだと云われたりしていたこのぼんやりと白いものがほんとうは何かご承知ですか。\n" +
89+
"\n" +
90+
"ではみなさんは、そういうふうに川だと云いわれたり、乳の流れたあとだと云われたりしていたこの<a href=\"https://www.aozora.gr.jp/cards/000081/files/456_15050.html\" target=\"_blank\" rel=\"noopener noreferrer\">ぼんやりと白いもの</a>がほんとうは何かご承知ですか。\n"
7691
}
7792
],
7893
invalid: [

0 commit comments

Comments
 (0)