mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Fix MD038 to handle text matches outside code span elements.
This commit is contained in:
parent
0f64bd5b4e
commit
74bd9b6e5b
2 changed files with 23 additions and 4 deletions
11
lib/rules.js
11
lib/rules.js
|
@ -933,15 +933,18 @@ module.exports = [
|
|||
"func": function MD038(params, errors) {
|
||||
forEachInlineChild(params, "code_inline",
|
||||
function forToken(token, inline) {
|
||||
var backtickPairs = "^(?:[^`]*`[^`]*`)*[^`]*";
|
||||
var escapedContent = escapeForRegExp(token.content);
|
||||
var left = (new RegExp("`\\s+" + escapedContent + "\\s*`"))
|
||||
var left = (new RegExp(
|
||||
backtickPairs + "(`\\s+" + escapedContent + "\\s*`)"))
|
||||
.exec(inline.content);
|
||||
var right = (new RegExp("`\\s*" + escapedContent + "\\s+`"))
|
||||
var right = (new RegExp(
|
||||
backtickPairs + "(`\\s*" + escapedContent + "\\s+`)"))
|
||||
.exec(inline.content);
|
||||
if (left) {
|
||||
errors.addContext(token.lineNumber, left[0]);
|
||||
errors.addContext(token.lineNumber, left[1]);
|
||||
} else if (right) {
|
||||
errors.addContext(token.lineNumber, right[0], false, true);
|
||||
errors.addContext(token.lineNumber, right[1], false, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue