mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-18 15:00:13 +01:00
Allow trailing spaces in code blocks
This commit is contained in:
parent
95d23b9a11
commit
2e391a5ca1
4 changed files with 18 additions and 3 deletions
|
|
@ -30,9 +30,11 @@ module.exports = {
|
||||||
listItemLineNumbers.sort((a, b) => a - b);
|
listItemLineNumbers.sort((a, b) => a - b);
|
||||||
}
|
}
|
||||||
const expected = (brSpaces < 2) ? 0 : brSpaces;
|
const expected = (brSpaces < 2) ? 0 : brSpaces;
|
||||||
forEachLine(lineMetadata(), (line, lineIndex) => {
|
let inFencedCode = 0;
|
||||||
|
forEachLine(lineMetadata(), (line, lineIndex, inCode, onFence) => {
|
||||||
|
inFencedCode += onFence;
|
||||||
const lineNumber = lineIndex + 1;
|
const lineNumber = lineIndex + 1;
|
||||||
if (trailingSpaceRe.test(line) &&
|
if ((!inCode || inFencedCode !== 0) && trailingSpaceRe.test(line) &&
|
||||||
!includesSorted(listItemLineNumbers, lineNumber)) {
|
!includesSorted(listItemLineNumbers, lineNumber)) {
|
||||||
const actual = line.length - line.trimRight().length;
|
const actual = line.length - line.trimRight().length;
|
||||||
if (expected !== actual) {
|
if (expected !== actual) {
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,16 @@ And here is more text
|
||||||
This is a code block that won't trigger.
|
This is a code block that won't trigger.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```text
|
||||||
|
This is code
|
||||||
|
|
||||||
|
with an empty line.
|
||||||
|
```
|
||||||
|
|
||||||
But we'll do another:
|
But we'll do another:
|
||||||
|
|
||||||
And this {MD046}
|
And this {MD046}
|
||||||
will.
|
will.
|
||||||
|
|
||||||
Final text is here
|
Final text is here
|
||||||
|
{MD009:14}
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,8 @@ But we'll do another:
|
||||||
And this
|
And this
|
||||||
will.
|
will.
|
||||||
|
|
||||||
Final text is here
|
One last one:
|
||||||
|
|
||||||
|
This is code
|
||||||
|
|
||||||
|
with an empty indented line.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
This line has a single trailing space {MD009}
|
This line has a single trailing space {MD009}
|
||||||
This line has two trailing spaces and should be allowed
|
This line has two trailing spaces and should be allowed
|
||||||
This line has three trailing spaces {MD009}
|
This line has three trailing spaces {MD009}
|
||||||
|
|
||||||
|
{MD009:4}
|
||||||
This line has four trailing spaces {MD009}
|
This line has four trailing spaces {MD009}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue