A custom markdownlint rule to enforce maximum one sentence per line.
When writing documentation, line-length often is not the most important rule. Some projects tend to ignore line-length and prefer an approach to limit each line to maximum one sentence. For example this allows:
For a better overview it often requires to split a sentence even over multiple lines, which we will not interfere with. This rule will only enforce maximum one sentence per line, but it will not rejoin sentences and adapt the structure, that one sentence will be on just one line.
Use following command to install
npm install markdownlint-rule-max-one-sentence-per-line --save-dev
Tags: sentences
Parameters:
context_length
: Size of context provided in error message (integer
,
default 14
)ignored_words
: Words which will be ignored during the detection
(string[]
, default ["ie","i.e","eg","e.g","etc","ex"]
)line_endings
: Recognized line-endings (string[]
, default [".","?","!"]
)sentence_start
: Regex for sentence start (string
, default
^\s+(\w|[*_'"])
)indentation
: Defines the used indentation (string
, default
``)Fixable: Some violations can be fixed by tooling
- First sentence. Second sentence.
+ First sentence.
+ Second sentence.
- > First sentence. Second sentence.
+ > First sentence.
+ > Second sentence.
- * First sentence. Second sentence.
+ * First sentence.
+ Second sentence. <!-- indentation based on provided configuration -->
For usage with certain tools, please refer to the documentation of markdownlint, markdownlint-cli or the tool you are using.
This code was/is based on sentences-per-line by @JoshuaKGoldberg.
Instead of parsing per line, we are utilizing the tokenization of markdownlint.
Without the groundwork of sentences-per-line
this rule would be for certain not in the state it is currently.