mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Add MD011 with tests, pass empty env to markdown-it.parse.
This commit is contained in:
parent
812f5bdfff
commit
f35d690fb1
3 changed files with 26 additions and 1 deletions
|
|
@ -17,7 +17,7 @@ function lintFile(file, config, callback) {
|
|||
if (err) {
|
||||
callback(err);
|
||||
} else {
|
||||
var tokens = md.parse(contents);
|
||||
var tokens = md.parse(contents, {});
|
||||
var lines = contents.split(/\r\n|\r|\n/g);
|
||||
tokens.forEach(function forToken(token) {
|
||||
if (token.lines) {
|
||||
|
|
|
|||
18
lib/rules.js
18
lib/rules.js
|
|
@ -194,6 +194,24 @@ module.exports = [
|
|||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "MD011",
|
||||
"desc": "Reversed link syntax",
|
||||
"func": function MD011(params, errors) {
|
||||
params.tokens.filter(function filterToken(token) {
|
||||
return (token.type === "inline");
|
||||
}).forEach(function forToken(token) {
|
||||
token.children.filter(function filterChild(child) {
|
||||
return (child.type === "text");
|
||||
}).forEach(function forChild(child) {
|
||||
if (child.content.match(/\([^)]+\)\[[^\]]+\]/)) {
|
||||
errors.push(token.lineNumber);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "MD031",
|
||||
"desc": "Fenced code blocks should be surrounded by blank lines",
|
||||
|
|
|
|||
7
test/reversed_link.md
Normal file
7
test/reversed_link.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
Go to (this website)[http://www.example.com] {MD011}
|
||||
|
||||
However, this shouldn't trigger inside code blocks:
|
||||
|
||||
myObj.getFiles("test")[0]
|
||||
|
||||
Nor inline code: `myobj.getFiles("test")[0]`
|
||||
Loading…
Add table
Add a link
Reference in a new issue