mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add MD033 with tests, rename test file.
This commit is contained in:
parent
1da7064094
commit
495fbac6fd
9 changed files with 49 additions and 5 deletions
|
@ -63,6 +63,7 @@ cases come directly from that project.
|
|||
* **MD030** - Spaces after list markers
|
||||
* **MD031** - Fenced code blocks should be surrounded by blank lines
|
||||
* **MD032** - Lists should be surrounded by blank lines
|
||||
* **MD033** - Inline HTML
|
||||
|
||||
See [Rules.md](doc/Rules.md) for more details.
|
||||
|
||||
|
|
16
doc/Rules.md
16
doc/Rules.md
|
@ -682,3 +682,19 @@ items with hanging indents are okay:
|
|||
|
||||
* This is
|
||||
okay
|
||||
|
||||
## MD033 - Inline HTML
|
||||
|
||||
Tags: html
|
||||
|
||||
This rule is triggered whenever raw HTML is used in a markdown document:
|
||||
|
||||
<h1>Inline HTML header</h1>
|
||||
|
||||
To fix this, use 'pure' markdown instead of including raw HTML:
|
||||
|
||||
# Markdown header
|
||||
|
||||
Rationale: Raw HTML is allowed in markdown, but this rule is included for
|
||||
those who want their documents to only include "pure" markdown, or for those
|
||||
who are rendering markdown documents in something other than HTML.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
var fs = require("fs");
|
||||
var md = require("markdown-it")();
|
||||
var md = require("markdown-it")({ "html": true });
|
||||
var rules = require("./rules");
|
||||
var shared = require("./shared");
|
||||
|
||||
|
|
12
lib/rules.js
12
lib/rules.js
|
@ -607,5 +607,17 @@ module.exports = [
|
|||
prevLine = line;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "MD033",
|
||||
"desc": "Inline HTML",
|
||||
"tags": [ "html" ],
|
||||
"func": function MD033(params, errors) {
|
||||
filterTokens(params.tokens, "html_inline", "html_block")
|
||||
.forEach(function forToken(token) {
|
||||
errors.push(token.lineNumber);
|
||||
});
|
||||
}
|
||||
}
|
||||
];
|
||||
|
|
|
@ -14,5 +14,6 @@
|
|||
"MD030": {
|
||||
"ul_multi": 3,
|
||||
"ol_multi": 2
|
||||
}
|
||||
},
|
||||
"MD033": false
|
||||
}
|
||||
|
|
|
@ -5,5 +5,6 @@
|
|||
"whitespace": false,
|
||||
"line_length": false,
|
||||
"MD006": false,
|
||||
"MD007": false
|
||||
"MD007": false,
|
||||
"MD033": false
|
||||
}
|
||||
|
|
13
test/inline_html.md
Normal file
13
test/inline_html.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Regular header
|
||||
|
||||
<h1>Inline HTML Header {MD033}</h1>
|
||||
|
||||
<p>More inline HTML {MD033}
|
||||
but this time on multiple lines
|
||||
</p>
|
||||
|
||||
<h1>This shouldn't trigger as it's inside a code block</h1>
|
||||
|
||||
```text
|
||||
<p>Neither should this as it's also in a code block</p>
|
||||
```
|
|
@ -498,7 +498,7 @@ module.exports.badFileSync = function badFileSync(test) {
|
|||
};
|
||||
|
||||
module.exports.readme = function readme(test) {
|
||||
test.expect(143);
|
||||
test.expect(144);
|
||||
fs.readFile("README.md", shared.utf8Encoding,
|
||||
function readFile(err, contents) {
|
||||
test.ifError(err);
|
||||
|
@ -555,7 +555,7 @@ module.exports.readme = function readme(test) {
|
|||
};
|
||||
|
||||
module.exports.doc = function doc(test) {
|
||||
test.expect(87);
|
||||
test.expect(90);
|
||||
fs.readFile("doc/Rules.md", shared.utf8Encoding,
|
||||
function readFile(err, contents) {
|
||||
test.ifError(err);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue