https://github.com/textlint-rule/textlint-rule-sentence-length
textlint rule that limit maximum length of sentence.
https://github.com/textlint-rule/textlint-rule-sentence-length
textlintrule
Last synced: 2 months ago
JSON representation
textlint rule that limit maximum length of sentence.
- Host: GitHub
- URL: https://github.com/textlint-rule/textlint-rule-sentence-length
- Owner: textlint-rule
- License: mit
- Created: 2015-11-15T14:33:55.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-08-14T11:14:21.000Z (11 months ago)
- Last Synced: 2025-04-23T01:16:49.910Z (2 months ago)
- Topics: textlintrule
- Language: TypeScript
- Homepage:
- Size: 478 KB
- Stars: 8
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# textlint-rule-sentence-length [](https://github.com/textlint-rule/textlint-rule-sentence-length/actions?query=workflow%3A"test")
[textlint](https://github.com/textlint/textlint "textlint") rule that limit Maximum Length of Sentence.
## Installation
npm install textlint-rule-sentence-length
## Usage
Add "sentence-length" to your `.textlintrc`.
```
{
"rules": {
"sentence-length": true
}
}
```### Options
- `max`
- default: 100
- The total number of characters allowed on each sentences.
- Sentence.length > 100 and throw Error
- `skipPatterns`: `string[]`
- 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
- `skipUrlStringLink`: `boolean`
- Default: `true`
- If it is `true`, skip url string link node like `` or `[https://example.com](https://example.com)`
- url string link is has the text which is same of url.
- `countBy`: `"codeunits" | "codepoints"`
- Determine how to count string length
- Issue:
- Default `"codeunits"````
{
"rules": {
"sentence-length": {
"max": 100
}
}
}
```Uncount `(...)` from `A sentence(...).`
```
{
"rules": {
"sentence-length": {
"max": 100,
"skipPatterns": [
"/\\(.*\\)$\\./"
]
}
}
}
```## A "Sentence"
This rule use [sentence-splitter](https://github.com/textlint-rule/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": [
"/\".*?\"/"
]
}
}
}
```## Exception
- 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 ↓
[textlint/textlint-filter-rule-comments: textlint filter rule that disables all rules between comments directive.](https://github.com/textlint/textlint-filter-rule-comments)
Very long https://example.com?longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong url.
```
**NG**:
This sentence includes one link and two Str.
```
This is [textlint/textlint-filter-rule-comments: textlint filter rule that disables all rules between comments directive.](https://github.com/textlint/textlint-filter-rule-comments).
```## Related Rules
See [Other rules](https://github.com/textlint/textlint/wiki/Collection-of-textlint-rule)
## Tests
npm test
## Contributing
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D## License
MIT