mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-24 01:40:13 +01:00
Update MD038/no-space-in-code to allow the "single leading and trailing space" scenario (fixes #271).
This commit is contained in:
parent
6ce426cf88
commit
65b19b703b
8 changed files with 102 additions and 79 deletions
|
|
@ -7,6 +7,7 @@ const { addErrorContext, filterTokens, forEachInlineCodeSpan, newLineRe } =
|
|||
|
||||
const leftSpaceRe = /^\s([^`]|$)/;
|
||||
const rightSpaceRe = /[^`]\s$/;
|
||||
const singleLeftRightSpaceRe = /^\s\S+\s$/;
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD038", "no-space-in-code" ],
|
||||
|
|
@ -32,7 +33,8 @@ module.exports = {
|
|||
rangeLineOffset = codeLines.length - 1;
|
||||
fixIndex = 0;
|
||||
}
|
||||
if (left || right) {
|
||||
const allowed = singleLeftRightSpaceRe.test(code);
|
||||
if ((left || right) && !allowed) {
|
||||
const codeLinesRange = codeLines[rangeLineOffset];
|
||||
if (codeLines.length > 1) {
|
||||
rangeLength = codeLinesRange.length + tickCount;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue