mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Ignore escaped backticks in code span elements per specification.
This commit is contained in:
parent
e2bdb522f5
commit
5a1fb40871
2 changed files with 16 additions and 4 deletions
|
@ -958,14 +958,14 @@ module.exports = [
|
|||
"aliases": [ "no-space-in-code" ],
|
||||
"regexp": spaceInsideCodeRe,
|
||||
"func": function MD038(params, errors) {
|
||||
var inlineCodeSpansRe = /(`+)((?:.*?[^`])|)\1(?!`)/g;
|
||||
var inlineCodeSpansRe = /(?:^|[^\\])((`+)((?:.*?[^`])|)\2(?!`))/g;
|
||||
forEachInlineChild(params, "code_inline",
|
||||
function forToken(token) {
|
||||
var line = params.lines[token.lineNumber - 1];
|
||||
var match = null;
|
||||
while ((match = inlineCodeSpansRe.exec(line)) !== null) {
|
||||
var inlineCodeSpan = match[0];
|
||||
var content = match[2];
|
||||
var inlineCodeSpan = match[1];
|
||||
var content = match[3];
|
||||
if (/^\s([^`]|$)/.test(content)) {
|
||||
errors.addContext(token.lineNumber, inlineCodeSpan);
|
||||
} else if (/[^`]\s$/.test(content)) {
|
||||
|
|
|
@ -40,7 +40,19 @@ text ```code``` text ``code `` text {MD038}
|
|||
|
||||
``embedded ` backtick`` text `code`
|
||||
|
||||
`backslash does not escape \` backtick`
|
||||
`backslash does not escape \` backtick in code span `
|
||||
|
||||
escaped \` backtick is ignored outside `code span`
|
||||
|
||||
`code` then escaped \` backtick
|
||||
|
||||
``code`` then escaped \` backtick then `code`
|
||||
|
||||
multiple \` escaped backticks \` in text
|
||||
|
||||
\` escaped backtick \` at start of text
|
||||
|
||||
text and ``\`code with ignored escaped \` backticks``
|
||||
|
||||
`` ` `` text `code`
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue