Ignore escaped backticks in code span elements per specification.

This commit is contained in:
David Anson 2017-03-13 21:29:24 -07:00
parent e2bdb522f5
commit 5a1fb40871
2 changed files with 16 additions and 4 deletions

View file

@ -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)) {

View file

@ -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`