mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Add MD020, MD021 with tests.
This commit is contained in:
parent
d0fcd32f3a
commit
35067149c9
3 changed files with 49 additions and 1 deletions
29
lib/rules.js
29
lib/rules.js
|
|
@ -270,7 +270,7 @@ module.exports = [
|
|||
"desc": "No space after hash on atx style header",
|
||||
"func": function MD018(params, errors) {
|
||||
params.lines.forEach(function forLine(line, lineIndex) {
|
||||
if (/^#+[^#\s]/.test(line)) {
|
||||
if (/^#+[^#\s]/.test(line) && !/#$/.test(line)) {
|
||||
errors.push(lineIndex + 1);
|
||||
}
|
||||
});
|
||||
|
|
@ -291,6 +291,33 @@ module.exports = [
|
|||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "MD020",
|
||||
"desc": "No space inside hashes on closed atx style header",
|
||||
"func": function MD020(params, errors) {
|
||||
params.lines.forEach(function forLine(line, lineIndex) {
|
||||
if (/^#+[^#]*[^\\]#+$/.test(line) &&
|
||||
(/^#+[^#\s]/.test(line) || /[^#\s]#+$/.test(line))) {
|
||||
errors.push(lineIndex + 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "MD021",
|
||||
"desc": "Multiple spaces inside hashes on closed atx style header",
|
||||
"func": function MD021(params, errors) {
|
||||
filterTokens(params.tokens, "heading_open")
|
||||
.forEach(function forToken(token) {
|
||||
if ((headingStyleFor(token) === "atx_closed") &&
|
||||
(/^#+\s\s/.test(token.line) || /\s\s#+$/.test(token.line))) {
|
||||
errors.push(token.lineNumber);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "MD028",
|
||||
"desc": "Blank line inside blockquote",
|
||||
|
|
|
|||
4
test/atx_closed_header_spacing.json
Normal file
4
test/atx_closed_header_spacing.json
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"default": true,
|
||||
"MD002": false
|
||||
}
|
||||
17
test/atx_closed_header_spacing.md
Normal file
17
test/atx_closed_header_spacing.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#Header 1 {MD020} #
|
||||
|
||||
## Header 2 {MD020}##
|
||||
|
||||
##Header 3 {MD020}##
|
||||
|
||||
## Header 4 {MD021} ##
|
||||
|
||||
## Header 5 {MD021} ##
|
||||
|
||||
## Header 6 {MD021} ##
|
||||
|
||||
## Header 7 {MD021} ##
|
||||
|
||||
## Header 8 \#
|
||||
|
||||
## Header 9 \#
|
||||
Loading…
Add table
Add a link
Reference in a new issue