textlint rule check sentence length
npm install textlint-rule-sentence-lengthtextlint rule that limit Maximum Length of Sentence.
npm install textlint-rule-sentence-length
Add "sentence-length" to your .textlintrc.
```
{
"rules": {
"sentence-length": true
}
}
- maxskipPatterns
- default: 100
- The total number of characters allowed on each sentences.
- Sentence.length > 100 and throw Error
- : string[]skipUrlStringLink
- A strings that match the patterns is uncounted of the sentence.
- Set an array of RegExp-like string.
- See https://github.com/textlint/regexp-string-matcher
- : booleantrue
- Default: true
- If it is , skip url string link node like or https://example.comcountBy
- url string link is has the text which is same of url.
- : "codeunits" | "codepoints""codeunits"
- Determine how to count string length
- Issue:
- Default
``
{
"rules": {
"sentence-length": {
"max": 100
}
}
}
Uncount (...) from A sentence(...).
``
{
"rules": {
"sentence-length": {
"max": 100,
"skipPatterns": [
"/\\(.*\\)$\\./"
]
}
}
}
This rule use sentence-splitter as library.
So the definition of "Sentence" is the same as sentence-splitter.
For example, the following text is 3 sentences.
``
We are talking about pens.
He said "This is a pen. I like it".
I could relate to that statement.
Second line includes "...", but this rule treat second line as a single sentence.
If you want to ignore "...", you can use skipPatterns option.
``
{
"rules": {
"sentence-length": {
"max": 100,
"skipPatterns": [
"/\".*?\"/"
]
}
}
}
- Except BlockQuote
- Except a single link node
- Except url string link (skipUrlStringLink)
OK:
`
> LONG LONG LONG LONG LONG LONG LONG LONG Quote text. But it is quote text.
a single link node ↓
Very long https://example.com?longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong url.
`
NG:
This sentence includes one link and two Str.
See Other rules
npm test
1. Fork it!
2. Create your feature branch: git checkout -b my-new-featuregit commit -am 'Add some feature'
3. Commit your changes: git push origin my-new-feature`
4. Push to the branch:
5. Submit a pull request :D
MIT