doesn't work for plain text files
io-monad opened this issue · 3 comments
This rule doesn't work for plain text files.
$ echo '材料不足で代替素材で製品を作った。' > test.txt
$ textlint --rule no-doubled-joshi test.txt
$
# No warnings output from textlint
It works for the same sentence in markdown files though.
$ echo '材料不足で代替素材で製品を作った。' > test.md
$ textlint --rule no-doubled-joshi test.md
/Users/io-monad/test.md
1:10 error 一文に二回以上利用されている助詞 "で" がみつかりました。 no-doubled-joshi
✖ 1 problem (1 error, 0 warnings)
It seems textlint core passes to [Syntax.Paragraph]
handler of the rule with a node of { type: "Paragraph", raw: "Blah Blah", range: ... }
and StringSource#toString()
of textlint-util-to-string returns an empty string for that node.
I'm not pretty sure whether this is a problem of textline-util-to-string or this rule, or perhaps textlint core.
Thanks.
EDIT: Oh, forgot to write some versions.
Tested with textlint 5.7.0
$ npm ls -g | grep textlint
├─┬ textlint@5.7.0
│ ├─┬ textlint-formatter@1.7.0
│ ├─┬ textlint-plugin-markdown@1.0.3
│ ├─┬ textlint-plugin-text@1.0.1
├─┬ textlint-rule-no-doubled-joshi@3.2.0
│ ├── textlint-rule-helper@1.1.5
│ └─┬ textlint-util-to-string@1.2.0
confirm txt-to-ast' bug
https://tonicdev.com/56e0d00573f4dc1100edb498/56e0d00573f4dc1100edb499
Str
Node of Document
should have raw
value, but it is missing.
{
"type": "Document",
"range": [
0,
3
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 3
}
},
"children": [
{
"type": "Paragraph",
"raw": "str",
"range": [
0,
3
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 3
}
},
"children": [
{
"type": "Str",
"raw": "str",
"range": [
0,
3
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 3
}
}
}
]
}
]
}
@io-monad I'v fixed this issue on txt-to-ast 1.1.0. @ textlint/txt-to-ast#1
Can you update txt-to-ast
and try again?
npm update
# or
npm i txt-to-ast
Great! I've just tested the fix and got correct output with txt-to-ast 1.1.0
$ echo '材料不足で代替素材で製品を作った。' > test.txt
$ textlint --rule no-doubled-joshi test.txt
/Users/io-monad/test.txt
1:10 error 一文に二回以上利用されている助詞 "で" がみつかりました。 no-doubled-joshi
✖ 1 problem (1 error, 0 warnings)
Thanks for the quick response.