markdownlint
Advanced tools
Comparing version 0.15.0 to 0.16.0
@@ -6,3 +6,4 @@ | ||
as well as an examples of documents that break the rule and corrected | ||
versions of the examples. | ||
versions of the examples. Any rule whose heading is ~~struck through~~ is | ||
deprecated, but still provided for backward-compatibility. | ||
@@ -47,3 +48,3 @@ <a name="md001"></a> | ||
## MD002 - First heading should be a top level heading | ||
## ~~MD002 - First heading should be a top level heading~~ | ||
@@ -796,4 +797,4 @@ Tags: headings, headers | ||
This rule is triggered on any heading that has a normal or full-width punctuation | ||
character as the last character in the line: | ||
This rule is triggered on any heading that has one of the specified normal or | ||
full-width punctuation characters as the last character in the line: | ||
@@ -804,3 +805,3 @@ ```markdown | ||
To fix this, remove any trailing punctuation: | ||
To fix this, remove the trailing punctuation: | ||
@@ -811,6 +812,7 @@ ```markdown | ||
Note: The punctuation parameter can be used to specify what characters class | ||
as punctuation at the end of the heading. For example, you can set it to | ||
`".,;:!"` to allow headings with question marks in them, such as might be used | ||
in an FAQ. | ||
Note: The `punctuation` parameter can be used to specify what characters count | ||
as punctuation at the end of a heading. For example, you can change it to | ||
`".,;:!"` to allow headings that end with a question mark, such as in an FAQ. | ||
Setting the `punctuation` parameter to `""` allows all characters - and is | ||
equivalent to disabling the rule. | ||
@@ -1021,2 +1023,4 @@ <a name="md027"></a> | ||
Parameters: list_items (boolean; default true) | ||
This rule is triggered when fenced code blocks are either not preceded or not | ||
@@ -1057,2 +1061,6 @@ followed by a blank line: | ||
Set the `list_items` parameter to `false` to disable this rule for list items. | ||
Disabling this behavior for lists can be useful if it is necessary to create a | ||
[tight](https://spec.commonmark.org/0.29/#tight) list containing a code fence. | ||
<a name="md032"></a> | ||
@@ -1059,0 +1067,0 @@ |
@@ -11,3 +11,4 @@ // @ts-check | ||
module.exports.frontMatterRe = | ||
/((^---$[^]*?^---$)|(^\+\+\+$[^]*?^(\+\+\+|\.\.\.)$))(\r\n|\r|\n|$)/m; | ||
// eslint-disable-next-line max-len | ||
/((^---\s*$[^]*?^---\s*$)|(^\+\+\+\s*$[^]*?^(\+\+\+|\.\.\.)\s*$))(\r\n|\r|\n|$)/m; | ||
@@ -153,3 +154,3 @@ // Regular expression for matching inline disable/enable comments | ||
const lineMetadata = params.lines.map(function mapLine(line, index) { | ||
return [ line, index, false, 0, false ]; | ||
return [ line, index, false, 0, false, false ]; | ||
}); | ||
@@ -173,2 +174,7 @@ filterTokens(params, "fence", function forToken(token) { | ||
}); | ||
filterTokens(params, "list_item_open", function forToken(token) { | ||
for (let i = token.map[0]; i < token.map[1]; i++) { | ||
lineMetadata[i][5] = true; | ||
} | ||
}); | ||
return lineMetadata; | ||
@@ -264,6 +270,21 @@ }; | ||
let currentTicks = 0; | ||
let state = "normal"; | ||
// Deliberate <= so trailing 0 completes the last span (ex: "text `code`") | ||
for (; index <= input.length; index++) { | ||
const char = input[index]; | ||
if (char === "`") { | ||
// Ignore backticks in link destination | ||
if ((char === "[") && (state === "normal")) { | ||
state = "linkTextOpen"; | ||
} else if ((char === "]") && (state === "linkTextOpen")) { | ||
state = "linkTextClosed"; | ||
} else if ((char === "(") && (state === "linkTextClosed")) { | ||
state = "linkDestinationOpen"; | ||
} else if ( | ||
((char === "(") && (state === "linkDestinationOpen")) || | ||
((char === ")") && (state === "linkDestinationOpen")) || | ||
(state === "linkTextClosed")) { | ||
state = "normal"; | ||
} | ||
// Parse backtick open/close | ||
if ((char === "`") && (state !== "linkDestinationOpen")) { | ||
// Count backticks at start or end of code span | ||
@@ -270,0 +291,0 @@ currentTicks++; |
{ | ||
"name": "markdownlint-rule-helpers", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "A collection of markdownlint helper functions for custom rules", | ||
@@ -5,0 +5,0 @@ "main": "helpers.js", |
@@ -5,4 +5,4 @@ // @ts-check | ||
const { addError, allPunctuation, forEachHeading, rangeFromRegExp } = | ||
require("../helpers"); | ||
const { addError, allPunctuation, escapeForRegExp, forEachHeading, | ||
rangeFromRegExp } = require("../helpers"); | ||
@@ -14,5 +14,9 @@ module.exports = { | ||
"function": function MD026(params, onError) { | ||
const punctuation = params.config.punctuation || allPunctuation; | ||
const trailingPunctuationRe = new RegExp("[" + punctuation + "]$"); | ||
forEachHeading(params, function forHeading(heading, content) { | ||
let punctuation = params.config.punctuation; | ||
if (punctuation === undefined) { | ||
punctuation = allPunctuation; | ||
} | ||
const trailingPunctuationRe = | ||
new RegExp("[" + escapeForRegExp(punctuation) + "]$"); | ||
forEachHeading(params, (heading, content) => { | ||
const match = trailingPunctuationRe.exec(content); | ||
@@ -19,0 +23,0 @@ if (match) { |
@@ -13,6 +13,9 @@ // @ts-check | ||
"function": function MD031(params, onError) { | ||
const listItems = params.config.list_items; | ||
const includeListItems = (listItems === undefined) ? true : !!listItems; | ||
const { lines } = params; | ||
forEachLine(lineMetadata(), (line, i, inCode, onFence) => { | ||
if (((onFence > 0) && !isBlankLine(lines[i - 1])) || | ||
((onFence < 0) && !isBlankLine(lines[i + 1]))) { | ||
forEachLine(lineMetadata(), (line, i, inCode, onFence, inTable, inItem) => { | ||
if ((((onFence > 0) && !isBlankLine(lines[i - 1])) || | ||
((onFence < 0) && !isBlankLine(lines[i + 1]))) && | ||
(includeListItems || !inItem)) { | ||
addErrorContext(onError, i + 1, lines[i].trim()); | ||
@@ -19,0 +22,0 @@ } |
@@ -9,3 +9,3 @@ // @ts-check | ||
const htmlElementRe = /<(([A-Za-z][A-Za-z0-9-]*)(?:[\s/][^>]*)?)>/g; | ||
const htmlElementRe = /<(([A-Za-z][A-Za-z0-9-]*)(?:\s[^>]*)?)\/?>/g; | ||
const linkDestinationRe = /]\(\s*$/; | ||
@@ -12,0 +12,0 @@ const inlineCodeRe = /^[^`]*(`+[^`]+`+[^`]+)*`+[^`]*$/; |
{ | ||
"name": "markdownlint", | ||
"version": "0.15.0", | ||
"version": "0.16.0", | ||
"description": "A Node.js style checker and lint tool for Markdown/CommonMark files.", | ||
@@ -30,9 +30,9 @@ "main": "lib/markdownlint.js", | ||
"dependencies": { | ||
"markdown-it": "8.4.2" | ||
"markdown-it": "9.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "~12.0.7", | ||
"browserify": "~16.2.3", | ||
"@types/node": "~12.6.9", | ||
"browserify": "~16.3.0", | ||
"cpy-cli": "~2.0.0", | ||
"eslint": "~5.16.0", | ||
"eslint": "~6.1.0", | ||
"glob": "~7.1.4", | ||
@@ -44,3 +44,3 @@ "js-yaml": "~3.13.1", | ||
"markdown-it-sup": "~1.0.0", | ||
"markdownlint-rule-helpers": "~0.2.1", | ||
"markdownlint-rule-helpers": "~0.3.0", | ||
"nodeunit": "~0.11.3", | ||
@@ -51,3 +51,3 @@ "nyc": "~14.1.1", | ||
"tv4": "~1.3.0", | ||
"typescript": "~3.5.1", | ||
"typescript": "~3.5.3", | ||
"uglify-js": "~3.6.0" | ||
@@ -54,0 +54,0 @@ }, |
@@ -50,3 +50,3 @@ # markdownlint | ||
* **[MD001](doc/Rules.md#md001)** *heading-increment/header-increment* - Heading levels should only increment by one level at a time | ||
* **[MD002](doc/Rules.md#md002)** *first-heading-h1/first-header-h1* - First heading should be a top level heading | ||
* ~~**[MD002](doc/Rules.md#md002)** *first-heading-h1/first-header-h1* - First heading should be a top level heading~~ | ||
* **[MD003](doc/Rules.md#md003)** *heading-style/header-style* - Heading style | ||
@@ -96,2 +96,4 @@ * **[MD004](doc/Rules.md#md004)** *ul-style* - Unordered list style | ||
~~Struck through~~ rules are deprecated, and provided for backward-compatibility. | ||
> All rules with `heading` as part of their name are also available as `header` | ||
@@ -370,3 +372,3 @@ > aliases (e.g. `heading-increment` is also available as `header-increment`). | ||
```js | ||
/((^---$[^]*?^---$)|(^\+\+\+$[^]*?^(\+\+\+|\.\.\.)$))(\r\n|\r|\n|$)/m | ||
/((^---\s*$[^]*?^---\s*$)|(^\+\+\+\s*$[^]*?^(\+\+\+|\.\.\.)\s*$))(\r\n|\r|\n|$)/m | ||
``` | ||
@@ -798,2 +800,4 @@ | ||
MD009/MD013/MD026/MD033/MD036, update dependencies. | ||
* 0.16.0 - Add custom rule sample for linting code, improve MD026/MD031/MD033/MD038, | ||
update dependencies. | ||
@@ -800,0 +804,0 @@ [npm-image]: https://img.shields.io/npm/v/markdownlint.svg |
@@ -241,2 +241,11 @@ "use strict"; | ||
break; | ||
case "MD031": | ||
scheme.properties = { | ||
"list_items": { | ||
"description": "Include list items", | ||
"type": "boolean", | ||
"default": true | ||
} | ||
}; | ||
break; | ||
case "MD033": | ||
@@ -243,0 +252,0 @@ scheme.properties = { |
@@ -870,9 +870,31 @@ { | ||
"description": "MD031/blanks-around-fences - Fenced code blocks should be surrounded by blank lines", | ||
"type": "boolean", | ||
"default": true | ||
"type": [ | ||
"boolean", | ||
"object" | ||
], | ||
"default": true, | ||
"properties": { | ||
"list_items": { | ||
"description": "Include list items", | ||
"type": "boolean", | ||
"default": true | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"blanks-around-fences": { | ||
"description": "MD031/blanks-around-fences - Fenced code blocks should be surrounded by blank lines", | ||
"type": "boolean", | ||
"default": true | ||
"type": [ | ||
"boolean", | ||
"object" | ||
], | ||
"default": true, | ||
"properties": { | ||
"list_items": { | ||
"description": "Include list items", | ||
"type": "boolean", | ||
"default": true | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
@@ -879,0 +901,0 @@ "MD032": { |
223861
4245
806
+ Addedmarkdown-it@9.0.1(transitive)
- Removedmarkdown-it@8.4.2(transitive)
Updatedmarkdown-it@9.0.1