项目作者: textlint-rule

项目描述 :
textlint rule that limit Maximum Length of Sentence.
高级语言: TypeScript
项目地址: git://github.com/textlint-rule/textlint-rule-sentence-length.git
创建时间: 2015-11-15T14:33:55Z
项目社区:https://github.com/textlint-rule/textlint-rule-sentence-length

开源协议:MIT License

下载


textlint-rule-sentence-length Actions Status: test

textlint rule that limit Maximum Length of Sentence.

Installation

  1. npm install textlint-rule-sentence-length

Usage

Add “sentence-length” to your .textlintrc.

  1. {
  2. "rules": {
  3. "sentence-length": true
  4. }
  5. }

Options

  • max
    • default: 100
    • The total number of characters allowed on each sentences.
    • Sentence.length > 100 and throw Error
  • skipPatterns: string[]
  • skipUrlStringLink: boolean
    • Default: true
    • If it is true, skip url string link node like <https:example.com> or [https://example.com](https://example.com)
    • url string link is has the text which is same of url.
  • countBy: "codeunits" | "codepoints"
  1. {
  2. "rules": {
  3. "sentence-length": {
  4. "max": 100
  5. }
  6. }
  7. }

Uncount (...) from A sentence(...).

  1. {
  2. "rules": {
  3. "sentence-length": {
  4. "max": 100,
  5. "skipPatterns": [
  6. "/\\(.*\\)$\\./"
  7. ]
  8. }
  9. }
  10. }

A “Sentence”

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.

  1. We are talking about pens.
  2. He said "This is a pen. I like it".
  3. I could relate to that statement.

Example sentences

Second line includes "...", but this rule treat second line as a single sentence.

If you want to ignore "...", you can use skipPatterns option.

  1. {
  2. "rules": {
  3. "sentence-length": {
  4. "max": 100,
  5. "skipPatterns": [
  6. "/\".*?\"/"
  7. ]
  8. }
  9. }
  10. }

Exception

  • Except BlockQuote
  • Except a single link node
  • Except url string link (skipUrlStringLink)

OK:

  1. > LONG LONG LONG LONG LONG LONG LONG LONG Quote text. But it is quote text.
  2. a single link node
  3. [textlint/textlint-filter-rule-comments: textlint filter rule that disables all rules between comments directive.](https://github.com/textlint/textlint-filter-rule-comments)
  4. Very long https://example.com?longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong url.

NG:

This sentence includes one link and two Str.

  1. 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).

See Other rules

Tests

  1. 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