mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Update MD013/line-length not to report long link-only lines (fixes #36).
This commit is contained in:
parent
acd36d5802
commit
0c1f40323d
2 changed files with 35 additions and 4 deletions
17
lib/rules.js
17
lib/rules.js
|
|
@ -56,7 +56,7 @@ function unorderedListStyleFor(token) {
|
|||
return "dash";
|
||||
case "+":
|
||||
return "plus";
|
||||
case "*":
|
||||
// case "*":
|
||||
default:
|
||||
return "asterisk";
|
||||
}
|
||||
|
|
@ -435,14 +435,25 @@ module.exports = [
|
|||
headerLineNumbers.push(heading.lineNumber);
|
||||
});
|
||||
}
|
||||
var re = longLineReFunc(params.options);
|
||||
var linkOnlyLineNumbers = [];
|
||||
filterTokens(params, "inline", function forToken(token) {
|
||||
if (((token.children.length === 2) || (token.children.length === 3)) &&
|
||||
(token.children[0].type === "link_open") &&
|
||||
(token.children[token.children.length - 1].type === "link_close")) {
|
||||
linkOnlyLineNumbers.push(token.lineNumber);
|
||||
}
|
||||
});
|
||||
var longLineRe = longLineReFunc(params.options);
|
||||
var labelRe = /^\s*\[.*[^\\]]:/;
|
||||
forEachLine(params,
|
||||
function forLine(line, lineIndex, inCode, onFence, inTable) {
|
||||
var lineNumber = lineIndex + 1;
|
||||
if ((includeCodeBlocks || !inCode) &&
|
||||
(includeTables || !inTable) &&
|
||||
(includeHeaders || (headerLineNumbers.indexOf(lineNumber)) < 0) &&
|
||||
re.test(line)) {
|
||||
(linkOnlyLineNumbers.indexOf(lineNumber) < 0) &&
|
||||
longLineRe.test(line) &&
|
||||
!labelRe.test(line)) {
|
||||
errors.addDetailIf(lineNumber, lineLength, line.length);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue