Improve MD038/no-space-in-code to allow single-spaces surrounding a code inline with internal spaces (fixes #277).

This commit is contained in:
David Anson 2020-04-24 19:52:28 -07:00
parent 2ae29e2b9e
commit bdc0246b34
2 changed files with 11 additions and 2 deletions

View file

@ -7,7 +7,7 @@ const { addErrorContext, filterTokens, forEachInlineCodeSpan, newLineRe } =
const leftSpaceRe = /^\s([^`]|$)/;
const rightSpaceRe = /[^`]\s$/;
const singleLeftRightSpaceRe = /^\s\S+\s$/;
const singleLeftRightSpaceRe = /^\s(?:\S.*\S|\S)\s$/;
module.exports = {
"names": [ "MD038", "no-space-in-code" ],

View file

@ -4,7 +4,7 @@
`codespan element with space inside right ` {MD038}
` codespan element with spaces inside ` {MD038}
` codespan element with spaces inside ` (allowed per spec)
empty `` codespan element
@ -111,3 +111,12 @@ Double start and single end space: ` code ` {MD038}
Single start and double end spaces: ` code ` {MD038}
Double start and end spaces: ` code ` {MD038}
Spaces before and after: ` codecode `
As above, with an internal space: ` code code `
As above, practical example with a backtick: `` Ctrl + ` ``
As above, no internal space: `` Ctrl+` ``
Again, 3 characters: ` abc `
Again, 2 characters: ` ab `
Again, 1 character: ` a `
Many internal spaces: ` code code code code code code `