mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-02-22 12:54:06 +01:00
Implement rule MD046/code-block-style from Ruby version.
This commit is contained in:
parent
c45eead5d7
commit
0af999e218
24 changed files with 236 additions and 19 deletions
|
|
@ -48,7 +48,7 @@ Note: Can not break MD025 and MD002 in the same file
|
|||
|
||||
```js
|
||||
```
|
||||
* list {MD032}
|
||||
* list {MD032} {MD046:49}
|
||||
|
||||
{MD031:50}
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ Code `with ` space {MD038}
|
|||
[link with space ](link) {MD039}
|
||||
|
||||
```
|
||||
code fence without language {MD040:73}
|
||||
code fence without language {MD040:73} {MD046:73}
|
||||
```
|
||||
|
||||
[empty link]() {MD042}
|
||||
|
|
|
|||
21
test/code-block-in-list.md
Normal file
21
test/code-block-in-list.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# Code Block in List
|
||||
|
||||
Text
|
||||
|
||||
```js
|
||||
// Code
|
||||
```
|
||||
|
||||
Text
|
||||
|
||||
1. Item
|
||||
|
||||
```js
|
||||
// Code
|
||||
```
|
||||
|
||||
1. Item
|
||||
|
||||
```js
|
||||
// Code
|
||||
```
|
||||
|
|
@ -18,7 +18,7 @@ if (true) {
|
|||
}
|
||||
```
|
||||
|
||||
if (true) {
|
||||
if (true) { // {MD046}
|
||||
console.log("true");
|
||||
if (false) {
|
||||
console.log("false");
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ if (true) {
|
|||
}
|
||||
```
|
||||
|
||||
if (true) {
|
||||
if (true) { // {MD046}
|
||||
console.log("true");
|
||||
if (false) {
|
||||
console.log("false");
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ Text text text text text text text text text text text text text text text text
|
|||
```
|
||||
|
||||
```text
|
||||
Text text text text text text text text text text text text text text text text text text.
|
||||
Text text text text text text text text text text text text text text text text text text. {MD046:21}
|
||||
```
|
||||
|
||||
Text text text text text text text text text text text text text text text text text text. {MD013}
|
||||
|
|
|
|||
11
test/code_block_consistency.md
Normal file
11
test/code_block_consistency.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
This is text.
|
||||
|
||||
This is a
|
||||
code block.
|
||||
|
||||
And here is more text
|
||||
|
||||
```text
|
||||
and here is a different {MD046:8}
|
||||
code block
|
||||
```
|
||||
|
|
@ -27,7 +27,7 @@ The following code block doesn't have any dollar signs, and shouldn't fire:
|
|||
cat bar
|
||||
|
||||
The following (fenced) code block doesn't have any content at all, and
|
||||
shouldn't fire:
|
||||
shouldn't fire: {MD046:32}
|
||||
|
||||
```bash
|
||||
```
|
||||
|
|
|
|||
6
test/code_block_fenced.json
Normal file
6
test/code_block_fenced.json
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"default": true,
|
||||
"MD046": {
|
||||
"style": "fenced"
|
||||
}
|
||||
}
|
||||
17
test/code_block_fenced.md
Normal file
17
test/code_block_fenced.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
This is text.
|
||||
|
||||
This is a {MD046}
|
||||
code block.
|
||||
|
||||
And here is more text
|
||||
|
||||
```text
|
||||
This is a code block that won't trigger.
|
||||
```
|
||||
|
||||
But we'll do another:
|
||||
|
||||
And this {MD046}
|
||||
will.
|
||||
|
||||
Final text is here
|
||||
6
test/code_block_indented.json
Normal file
6
test/code_block_indented.json
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"default": true,
|
||||
"MD046": {
|
||||
"style": "indented"
|
||||
}
|
||||
}
|
||||
17
test/code_block_indented.md
Normal file
17
test/code_block_indented.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
This is text.
|
||||
|
||||
This is a
|
||||
code block.
|
||||
|
||||
And here is more text
|
||||
|
||||
```text
|
||||
This is {MD046:8} also a code block.
|
||||
```
|
||||
|
||||
But we'll do another:
|
||||
|
||||
And this
|
||||
will.
|
||||
|
||||
Final text is here
|
||||
|
|
@ -17,3 +17,9 @@ MarkDownLint.
|
|||
A [normal](link) and an [empty one]() and a [fragment](#one).
|
||||
|
||||
An image without alternate text 
|
||||
|
||||
```text
|
||||
Fenced code
|
||||
```
|
||||
|
||||
Indented code
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
"errorRange": [25, 13]
|
||||
},
|
||||
{
|
||||
"lineNumber": 20,
|
||||
"lineNumber": 26,
|
||||
"ruleNames": [ "MD043", "required-headings", "required-headers" ],
|
||||
"ruleDescription": "Required heading structure",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md043",
|
||||
|
|
@ -88,5 +88,14 @@
|
|||
"errorDetail": null,
|
||||
"errorContext": null,
|
||||
"errorRange": null
|
||||
},
|
||||
{
|
||||
"lineNumber": 25,
|
||||
"ruleNames": [ "MD046", "code-block-style" ],
|
||||
"ruleDescription": "Code block style",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md046",
|
||||
"errorDetail": "Expected: fenced; Actual: indented",
|
||||
"errorContext": null,
|
||||
"errorRange": null
|
||||
}
|
||||
]
|
||||
|
|
@ -9,5 +9,5 @@ but this time on multiple lines
|
|||
<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>
|
||||
<p>Neither should this as it's also in a code block {MD046:11}</p>
|
||||
```
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ This line however, while very long, doesn't have whitespace after the 80th colum
|
|||
[This long line is comprised entirely of a link](https://example.com "But is inside a code block") {MD013}
|
||||
|
||||
```markdown
|
||||
[This long line is comprised entirely of a link](https://example.com "But is inside a code block") {MD013}
|
||||
[This long line is comprised entirely of a link](https://example.com "But is inside a code block") {MD013} {MD046:11}
|
||||
```
|
||||
|
||||
This [long line is comprised mostly of a link](https://example.com "This is the long link's title") {MD013}
|
||||
|
|
|
|||
|
|
@ -810,7 +810,8 @@ module.exports.styleAll = function styleAll(test) {
|
|||
"MD040": [ 73 ],
|
||||
"MD041": [ 1 ],
|
||||
"MD042": [ 77 ],
|
||||
"MD045": [ 81 ]
|
||||
"MD045": [ 81 ],
|
||||
"MD046": [ 49, 73 ]
|
||||
}
|
||||
};
|
||||
test.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
||||
|
|
@ -849,7 +850,8 @@ module.exports.styleRelaxed = function styleRelaxed(test) {
|
|||
"MD035": [ 61 ],
|
||||
"MD036": [ 65 ],
|
||||
"MD042": [ 77 ],
|
||||
"MD045": [ 81 ]
|
||||
"MD045": [ 81 ],
|
||||
"MD046": [ 49, 73 ]
|
||||
}
|
||||
};
|
||||
test.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
||||
|
|
@ -1091,7 +1093,7 @@ module.exports.missingStringValue = function missingStringValue(test) {
|
|||
};
|
||||
|
||||
module.exports.readme = function readme(test) {
|
||||
test.expect(109);
|
||||
test.expect(111);
|
||||
const tagToRules = {};
|
||||
rules.forEach(function forRule(rule) {
|
||||
rule.tags.forEach(function forTag(tag) {
|
||||
|
|
@ -1157,7 +1159,7 @@ module.exports.readme = function readme(test) {
|
|||
};
|
||||
|
||||
module.exports.doc = function doc(test) {
|
||||
test.expect(312);
|
||||
test.expect(320);
|
||||
fs.readFile("doc/Rules.md", helpers.utf8Encoding,
|
||||
function readFile(err, contents) {
|
||||
test.ifError(err);
|
||||
|
|
@ -1885,7 +1887,7 @@ module.exports.configBadHybridSync = function configBadHybridSync(test) {
|
|||
|
||||
module.exports.allBuiltInRulesHaveValidUrl =
|
||||
function allBuiltInRulesHaveValidUrl(test) {
|
||||
test.expect(123);
|
||||
test.expect(126);
|
||||
rules.forEach(function forRule(rule) {
|
||||
test.ok(rule.information);
|
||||
test.ok(Object.getPrototypeOf(rule.information) === URL.prototype);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ Execute `via the node.js engine`
|
|||
node.js is runtime
|
||||
|
||||
```js
|
||||
javascript is code
|
||||
javascript is code {MD046:18}
|
||||
node.js is runtime
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ HTML <u>javascript</u> {MD033} {MD044}
|
|||
node.js is runtime {MD044}
|
||||
|
||||
```js
|
||||
javascript is code {MD044}
|
||||
javascript is code {MD044} {MD046:54}
|
||||
node.js is runtime {MD044}
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue