Add fenced code block style rule (#224) (fixes #223).

This commit is contained in:
Marius Lichtblau 2019-10-08 21:10:02 -07:00 committed by David Anson
parent fd06a50ee5
commit e9b3cc4c18
17 changed files with 232 additions and 25 deletions

View file

@ -74,6 +74,10 @@ Code `with ` space {MD038}
code fence without language {MD040:73} {MD046:73}
```
~~~js
code fence with different style {MD048:77} {MD046:77}
~~~
[empty link]() {MD042}
markdownLint {MD044}

View file

@ -0,0 +1,6 @@
{
"default": true,
"MD048": {
"style": "backtick"
}
}

View file

@ -0,0 +1,19 @@
```text
This is a code block
```
~~~text
This is {MD048:5} a code block
~~~
```text
~~~
This is fine
~~~
```
~~~text
```
This is not {MD048:15}
```
~~~

View file

@ -0,0 +1,6 @@
{
"default": true,
"MD048": {
"style": "tilde"
}
}

View file

@ -0,0 +1,19 @@
```text
This is {MD048:1} a code block
```
~~~text
This is a code block
~~~
```text
~~~
This is not fine {MD048:9}
~~~
```
~~~text
```
This is
```
~~~

View file

@ -24,4 +24,8 @@ Fenced code
Indented code
~~~text
Fenced code
~~~
Missing newline character

View file

@ -24,4 +24,8 @@ Fenced code
Indented code
~~~text
Fenced code
~~~
Missing newline character

View file

@ -45,7 +45,7 @@
"errorRange": [25, 13]
},
{
"lineNumber": 27,
"lineNumber": 31,
"ruleNames": [ "MD043", "required-headings", "required-headers" ],
"ruleDescription": "Required heading structure",
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md043",
@ -99,12 +99,21 @@
"errorRange": null
},
{
"lineNumber": 27,
"lineNumber": 31,
"ruleNames": [ "MD047", "single-trailing-newline" ],
"ruleDescription": "Files should end with a single newline character",
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md047",
"errorDetail": null,
"errorContext": null,
"errorRange": [ 25, 1 ]
},
{
"lineNumber": 27,
"ruleNames": [ "MD048", "code-fence-style" ],
"ruleDescription": "Code fence style",
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md048",
"errorDetail": "Expected: backtick; Actual: tilde",
"errorContext": null,
"errorRange": null
}
]

View file

@ -24,4 +24,4 @@ None of the above should trigger any heading related rules.
Code block without a language specifier
```
{MD040:23}
{MD040:23} {MD048:13}

View file

@ -4,7 +4,7 @@ text {MD031:4}
```fence
code {MD031:6}
```
text {MD031:8}
text {MD031:8} {MD048:8}
~~~fence
code
~~~
@ -14,7 +14,7 @@ text {MD031:10} {MD031:12}
code
~~~
```
text {MD031:16} {MD031:18}
text {MD031:16} {MD031:18} {MD048:18}
~~~fence
```fence
code
@ -28,7 +28,7 @@ code
~~~
```
text {MD031:30} {MD031:32}
text {MD031:30} {MD031:32} {MD048:32}
~~~fence
```fence
@ -41,7 +41,7 @@ text {MD031:38} {MD031:40}
code
~~~
```
text {MD031:43} {MD031:45}
text {MD031:43} {MD031:45} {MD048:45}
~~~fence
code
```
@ -52,7 +52,7 @@ text {MD031:48} {MD031:50}
code
```
````
text {MD031:54} {MD031:56}
text {MD031:54} {MD031:56} {MD048:56}
~~~~fence
~~~fence
code
@ -64,7 +64,7 @@ text {MD031:60} {MD031:62}
code
```
`````
text {MD031:66} {MD031:68}
text {MD031:66} {MD031:68} {MD048:68}
~~~~fence
~~~fence
code

View file

@ -1124,7 +1124,7 @@ module.exports.styleAll = function styleAll(test) {
"MD019": [ 27 ],
"MD020": [ 29 ],
"MD021": [ 31 ],
"MD022": [ 82 ],
"MD022": [ 86 ],
"MD023": [ 40 ],
"MD024": [ 35 ],
"MD026": [ 40 ],
@ -1143,10 +1143,11 @@ module.exports.styleAll = function styleAll(test) {
"MD039": [ 71 ],
"MD040": [ 73 ],
"MD041": [ 1 ],
"MD042": [ 77 ],
"MD045": [ 81 ],
"MD046": [ 49, 73 ],
"MD047": [ 84 ]
"MD042": [ 81 ],
"MD045": [ 85 ],
"MD046": [ 49, 73, 77 ],
"MD047": [ 88 ],
"MD048": [ 77 ]
}
};
test.deepEqual(actualResult, expectedResult, "Undetected issues.");
@ -1175,7 +1176,7 @@ module.exports.styleRelaxed = function styleRelaxed(test) {
"MD019": [ 27 ],
"MD020": [ 29 ],
"MD021": [ 31 ],
"MD022": [ 82 ],
"MD022": [ 86 ],
"MD023": [ 40 ],
"MD024": [ 35 ],
"MD026": [ 40 ],
@ -1184,10 +1185,11 @@ module.exports.styleRelaxed = function styleRelaxed(test) {
"MD032": [ 7, 8, 51 ],
"MD035": [ 61 ],
"MD036": [ 65 ],
"MD042": [ 77 ],
"MD045": [ 81 ],
"MD046": [ 49, 73 ],
"MD047": [ 84 ]
"MD042": [ 81 ],
"MD045": [ 85 ],
"MD046": [ 49, 73, 77 ],
"MD047": [ 88 ],
"MD048": [ 77 ]
}
};
test.deepEqual(actualResult, expectedResult, "Undetected issues.");
@ -1430,7 +1432,7 @@ module.exports.missingStringValue = function missingStringValue(test) {
};
module.exports.readme = function readme(test) {
test.expect(113);
test.expect(115);
const tagToRules = {};
rules.forEach(function forRule(rule) {
rule.tags.forEach(function forTag(tag) {
@ -1499,7 +1501,7 @@ module.exports.readme = function readme(test) {
};
module.exports.doc = function doc(test) {
test.expect(328);
test.expect(336);
fs.readFile("doc/Rules.md", helpers.utf8Encoding,
function readFile(err, contents) {
test.ifError(err);
@ -2787,7 +2789,7 @@ module.exports.configBadHybridSync = function configBadHybridSync(test) {
module.exports.allBuiltInRulesHaveValidUrl =
function allBuiltInRulesHaveValidUrl(test) {
test.expect(129);
test.expect(132);
rules.forEach(function forRule(rule) {
test.ok(rule.information);
test.ok(Object.getPrototypeOf(rule.information) === URL.prototype);