mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-22 17:00:13 +01:00
Update to version 0.20.3.
This commit is contained in:
parent
a66892a6bb
commit
a794118a8d
4 changed files with 80 additions and 45 deletions
|
|
@ -858,11 +858,12 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
|
||||||
MD005/list-indent, improve MD007/MD013/MD014, deprecate MD006/ul-start-left, add
|
MD005/list-indent, improve MD007/MD013/MD014, deprecate MD006/ul-start-left, add
|
||||||
rationale for every rule, update test runner and code coverage, add more JSDoc
|
rationale for every rule, update test runner and code coverage, add more JSDoc
|
||||||
comments, update dependencies.
|
comments, update dependencies.
|
||||||
* 0.20.0 - Add `markdownlint-configure-file` inline comment,
|
* 0.20.0 - Add `markdownlint-configure-file` inline comment, reimplement MD037,
|
||||||
improve MD005/MD007/MD013/MD018/MD029/MD031/MD034/MD037/MD038/MD039, improve HTML
|
improve MD005/MD007/MD013/MD018/MD029/MD031/MD034/MD038/MD039, improve HTML
|
||||||
comment handling, update dependencies.
|
comment handling, update dependencies.
|
||||||
* 0.20.1 - Fix regression in MD037.
|
* 0.20.1 - Fix regression in MD037.
|
||||||
* 0.20.2 - Fix regression in MD037, improve MD038.
|
* 0.20.2 - Fix regression in MD037, improve MD038.
|
||||||
|
* 0.20.3 - Fix regression in MD037, improve MD044, add automatic regression testing.
|
||||||
|
|
||||||
[npm-image]: https://img.shields.io/npm/v/markdownlint.svg
|
[npm-image]: https://img.shields.io/npm/v/markdownlint.svg
|
||||||
[npm-url]: https://www.npmjs.com/package/markdownlint
|
[npm-url]: https://www.npmjs.com/package/markdownlint
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,10 @@ module.exports.inlineCommentRe = inlineCommentRe;
|
||||||
module.exports.bareUrlRe = /(?:http|ftp)s?:\/\/[^\s\]"']*/ig;
|
module.exports.bareUrlRe = /(?:http|ftp)s?:\/\/[^\s\]"']*/ig;
|
||||||
module.exports.listItemMarkerRe = /^([\s>]*)(?:[*+-]|\d+[.)])\s+/;
|
module.exports.listItemMarkerRe = /^([\s>]*)(?:[*+-]|\d+[.)])\s+/;
|
||||||
module.exports.orderedListItemMarkerRe = /^[\s>]*0*(\d+)[.)]/;
|
module.exports.orderedListItemMarkerRe = /^[\s>]*0*(\d+)[.)]/;
|
||||||
// Regular expression for emphasis markers
|
// Regular expression for all instances of emphasis markers
|
||||||
var emphasisMarkersRe = /[_*]+/g;
|
var emphasisMarkersRe = /[_*]/g;
|
||||||
|
// Regular expression for inline links and shortcut reference links
|
||||||
|
var linkRe = /\[(?:[^[\]]|\[[^\]]*\])*\](?:\(\S*\))?/g;
|
||||||
// readFile options for reading with the UTF-8 encoding
|
// readFile options for reading with the UTF-8 encoding
|
||||||
module.exports.utf8Encoding = { "encoding": "utf8" };
|
module.exports.utf8Encoding = { "encoding": "utf8" };
|
||||||
// All punctuation characters (normal and full-width)
|
// All punctuation characters (normal and full-width)
|
||||||
|
|
@ -246,7 +248,7 @@ module.exports.getLineMetadata = function getLineMetadata(params) {
|
||||||
// Calls the provided function for each line (with context)
|
// Calls the provided function for each line (with context)
|
||||||
module.exports.forEachLine = function forEachLine(lineMetadata, handler) {
|
module.exports.forEachLine = function forEachLine(lineMetadata, handler) {
|
||||||
lineMetadata.forEach(function forMetadata(metadata) {
|
lineMetadata.forEach(function forMetadata(metadata) {
|
||||||
// Parameters: line, lineIndex, inCode, onFence, inTable, inBreak
|
// Parameters: line, lineIndex, inCode, onFence, inTable, inItem, inBreak
|
||||||
handler.apply(void 0, metadata);
|
handler.apply(void 0, metadata);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -482,14 +484,15 @@ module.exports.frontMatterHasTitle =
|
||||||
frontMatterLines.some(function (line) { return frontMatterTitleRe.test(line); });
|
frontMatterLines.some(function (line) { return frontMatterTitleRe.test(line); });
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Returns a list of emphasis markers in code spans.
|
* Returns a list of emphasis markers in code spans and links.
|
||||||
*
|
*
|
||||||
* @param {Object} params RuleParams instance.
|
* @param {Object} params RuleParams instance.
|
||||||
* @returns {number[][]} List of markers.
|
* @returns {number[][]} List of markers.
|
||||||
*/
|
*/
|
||||||
function emphasisMarkersInCodeSpans(params) {
|
function emphasisMarkersInContent(params) {
|
||||||
var lines = params.lines;
|
var lines = params.lines;
|
||||||
var byLine = new Array(lines.length);
|
var byLine = new Array(lines.length);
|
||||||
|
// Search code spans
|
||||||
filterTokens(params, "inline", function (token) {
|
filterTokens(params, "inline", function (token) {
|
||||||
var children = token.children, lineNumber = token.lineNumber, map = token.map;
|
var children = token.children, lineNumber = token.lineNumber, map = token.map;
|
||||||
if (children.some(function (child) { return child.type === "code_inline"; })) {
|
if (children.some(function (child) { return child.type === "code_inline"; })) {
|
||||||
|
|
@ -509,9 +512,21 @@ function emphasisMarkersInCodeSpans(params) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// Search links
|
||||||
|
lines.forEach(function (tokenLine, tokenLineIndex) {
|
||||||
|
var linkMatch = null;
|
||||||
|
while ((linkMatch = linkRe.exec(tokenLine))) {
|
||||||
|
var markerMatch = null;
|
||||||
|
while ((markerMatch = emphasisMarkersRe.exec(linkMatch[0]))) {
|
||||||
|
var inLine = byLine[tokenLineIndex] || [];
|
||||||
|
inLine.push(linkMatch.index + markerMatch.index);
|
||||||
|
byLine[tokenLineIndex] = inLine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return byLine;
|
return byLine;
|
||||||
}
|
}
|
||||||
module.exports.emphasisMarkersInCodeSpans = emphasisMarkersInCodeSpans;
|
module.exports.emphasisMarkersInContent = emphasisMarkersInContent;
|
||||||
/**
|
/**
|
||||||
* Gets the most common line ending, falling back to the platform default.
|
* Gets the most common line ending, falling back to the platform default.
|
||||||
*
|
*
|
||||||
|
|
@ -2741,10 +2756,10 @@ module.exports = {
|
||||||
},{"../helpers":2}],37:[function(require,module,exports){
|
},{"../helpers":2}],37:[function(require,module,exports){
|
||||||
// @ts-check
|
// @ts-check
|
||||||
"use strict";
|
"use strict";
|
||||||
var _a = require("../helpers"), addErrorContext = _a.addErrorContext, emphasisMarkersInCodeSpans = _a.emphasisMarkersInCodeSpans, forEachLine = _a.forEachLine, includesSorted = _a.includesSorted, isBlankLine = _a.isBlankLine;
|
var _a = require("../helpers"), addErrorContext = _a.addErrorContext, emphasisMarkersInContent = _a.emphasisMarkersInContent, forEachLine = _a.forEachLine, isBlankLine = _a.isBlankLine;
|
||||||
var lineMetadata = require("./cache").lineMetadata;
|
var lineMetadata = require("./cache").lineMetadata;
|
||||||
var emphasisRe = /(^|[^\\])(?:(\*\*?\*?)|(__?_?))/g;
|
var emphasisRe = /(^|[^\\]|\\\\)(?:(\*\*?\*?)|(__?_?))/g;
|
||||||
var asteriskListItemMarkerRe = /^(\s*)\*(\s+)/;
|
var asteriskListItemMarkerRe = /^([\s>]*)\*(\s+)/;
|
||||||
var leftSpaceRe = /^\s+/;
|
var leftSpaceRe = /^\s+/;
|
||||||
var rightSpaceRe = /\s+$/;
|
var rightSpaceRe = /\s+$/;
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
@ -2801,7 +2816,7 @@ module.exports = {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// Initialize
|
// Initialize
|
||||||
var ignoreMarkersByLine = emphasisMarkersInCodeSpans(params);
|
var ignoreMarkersByLine = emphasisMarkersInContent(params);
|
||||||
resetRunTracking();
|
resetRunTracking();
|
||||||
forEachLine(lineMetadata(), function (line, lineIndex, inCode, onFence, inTable, inItem, onBreak) {
|
forEachLine(lineMetadata(), function (line, lineIndex, inCode, onFence, inTable, inItem, onBreak) {
|
||||||
var onItemStart = (inItem === 1);
|
var onItemStart = (inItem === 1);
|
||||||
|
|
@ -2822,8 +2837,8 @@ module.exports = {
|
||||||
while ((match = emphasisRe.exec(line))) {
|
while ((match = emphasisRe.exec(line))) {
|
||||||
var ignoreMarkersForLine = ignoreMarkersByLine[lineIndex] || [];
|
var ignoreMarkersForLine = ignoreMarkersByLine[lineIndex] || [];
|
||||||
var matchIndex = match.index + match[1].length;
|
var matchIndex = match.index + match[1].length;
|
||||||
if (includesSorted(ignoreMarkersForLine, matchIndex)) {
|
if (ignoreMarkersForLine.includes(matchIndex)) {
|
||||||
// Ignore emphasis markers inside code spans
|
// Ignore emphasis markers inside code spans and links
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var matchLength = match[0].length - match[1].length;
|
var matchLength = match[0].length - match[1].length;
|
||||||
|
|
@ -2835,8 +2850,9 @@ module.exports = {
|
||||||
emphasisKind = matchKind;
|
emphasisKind = matchKind;
|
||||||
effectiveEmphasisLength = matchLength;
|
effectiveEmphasisLength = matchLength;
|
||||||
}
|
}
|
||||||
else if ((matchLength === effectiveEmphasisLength) &&
|
else if (matchKind === emphasisKind) {
|
||||||
(matchKind === emphasisKind)) {
|
// Matching emphasis markers
|
||||||
|
if (matchLength === effectiveEmphasisLength) {
|
||||||
// Ending an existing run, report any pending error
|
// Ending an existing run, report any pending error
|
||||||
if (pendingError) {
|
if (pendingError) {
|
||||||
addErrorContext.apply(void 0, pendingError);
|
addErrorContext.apply(void 0, pendingError);
|
||||||
|
|
@ -2861,6 +2877,15 @@ module.exports = {
|
||||||
// Upgrade to internal run (1->3 or 2->3)
|
// Upgrade to internal run (1->3 or 2->3)
|
||||||
effectiveEmphasisLength += matchLength;
|
effectiveEmphasisLength += matchLength;
|
||||||
}
|
}
|
||||||
|
// Back up one character so RegExp has a chance to match the
|
||||||
|
// next marker (ex: "**star**_underscore_")
|
||||||
|
emphasisRe.lastIndex--;
|
||||||
|
}
|
||||||
|
else if (emphasisRe.lastIndex > 1) {
|
||||||
|
// Back up one character so RegExp has a chance to match the
|
||||||
|
// mis-matched marker (ex: "*text_*")
|
||||||
|
emphasisRe.lastIndex--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (emphasisIndex !== -1) {
|
if (emphasisIndex !== -1) {
|
||||||
pendingError = pendingError ||
|
pendingError = pendingError ||
|
||||||
|
|
@ -3147,12 +3172,15 @@ module.exports = {
|
||||||
// Attempt to fix bad offset due to inline content
|
// Attempt to fix bad offset due to inline content
|
||||||
matchIndex = fullLine.indexOf(wordMatch);
|
matchIndex = fullLine.indexOf(wordMatch);
|
||||||
}
|
}
|
||||||
var range = [matchIndex + 1, matchLength];
|
var range = (matchIndex === -1) ?
|
||||||
addErrorDetailIf(onError, lineNumber, name, match[1], null, null, range, {
|
null :
|
||||||
|
[matchIndex + 1, matchLength];
|
||||||
|
var fixInfo = (matchIndex === -1) ? null : {
|
||||||
"editColumn": matchIndex + 1,
|
"editColumn": matchIndex + 1,
|
||||||
"deleteCount": matchLength,
|
"deleteCount": matchLength,
|
||||||
"insertText": name
|
"insertText": name
|
||||||
});
|
};
|
||||||
|
addErrorDetailIf(onError, lineNumber, name, match[1], null, null, range, fixInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3317,7 +3345,7 @@ module.exports = rules;
|
||||||
},{"../package.json":50,"./md001":5,"./md002":6,"./md003":7,"./md004":8,"./md005":9,"./md006":10,"./md007":11,"./md009":12,"./md010":13,"./md011":14,"./md012":15,"./md013":16,"./md014":17,"./md018":18,"./md019":19,"./md020":20,"./md021":21,"./md022":22,"./md023":23,"./md024":24,"./md025":25,"./md026":26,"./md027":27,"./md028":28,"./md029":29,"./md030":30,"./md031":31,"./md032":32,"./md033":33,"./md034":34,"./md035":35,"./md036":36,"./md037":37,"./md038":38,"./md039":39,"./md040":40,"./md041":41,"./md042":42,"./md043":43,"./md044":44,"./md045":45,"./md046":46,"./md047":47,"./md048":48,"url":59}],50:[function(require,module,exports){
|
},{"../package.json":50,"./md001":5,"./md002":6,"./md003":7,"./md004":8,"./md005":9,"./md006":10,"./md007":11,"./md009":12,"./md010":13,"./md011":14,"./md012":15,"./md013":16,"./md014":17,"./md018":18,"./md019":19,"./md020":20,"./md021":21,"./md022":22,"./md023":23,"./md024":24,"./md025":25,"./md026":26,"./md027":27,"./md028":28,"./md029":29,"./md030":30,"./md031":31,"./md032":32,"./md033":33,"./md034":34,"./md035":35,"./md036":36,"./md037":37,"./md038":38,"./md039":39,"./md040":40,"./md041":41,"./md042":42,"./md043":43,"./md044":44,"./md045":45,"./md046":46,"./md047":47,"./md048":48,"url":59}],50:[function(require,module,exports){
|
||||||
module.exports={
|
module.exports={
|
||||||
"name": "markdownlint",
|
"name": "markdownlint",
|
||||||
"version": "0.20.1",
|
"version": "0.20.3",
|
||||||
"description": "A Node.js style checker and lint tool for Markdown/CommonMark files.",
|
"description": "A Node.js style checker and lint tool for Markdown/CommonMark files.",
|
||||||
"main": "lib/markdownlint.js",
|
"main": "lib/markdownlint.js",
|
||||||
"types": "lib/markdownlint.d.ts",
|
"types": "lib/markdownlint.d.ts",
|
||||||
|
|
@ -3341,7 +3369,11 @@ module.exports={
|
||||||
"build-declaration": "tsc --allowJs --declaration --outDir declaration --resolveJsonModule lib/markdownlint.js && cpy declaration/lib/markdownlint.d.ts lib && rimraf declaration",
|
"build-declaration": "tsc --allowJs --declaration --outDir declaration --resolveJsonModule lib/markdownlint.js && cpy declaration/lib/markdownlint.d.ts lib && rimraf declaration",
|
||||||
"build-demo": "cpy node_modules/markdown-it/dist/markdown-it.min.js demo && cd demo && rimraf markdownlint-browser.* && cpy file-header.js . --rename=markdownlint-browser.js && tsc --allowJs --resolveJsonModule --outDir ../lib-es3 ../lib/markdownlint.js && cpy ../helpers/package.json ../lib-es3/helpers && browserify ../lib-es3/lib/markdownlint.js --standalone markdownlint >> markdownlint-browser.js && uglifyjs markdownlint-browser.js --compress --mangle --comments --output markdownlint-browser.min.js",
|
"build-demo": "cpy node_modules/markdown-it/dist/markdown-it.min.js demo && cd demo && rimraf markdownlint-browser.* && cpy file-header.js . --rename=markdownlint-browser.js && tsc --allowJs --resolveJsonModule --outDir ../lib-es3 ../lib/markdownlint.js && cpy ../helpers/package.json ../lib-es3/helpers && browserify ../lib-es3/lib/markdownlint.js --standalone markdownlint >> markdownlint-browser.js && uglifyjs markdownlint-browser.js --compress --mangle --comments --output markdownlint-browser.min.js",
|
||||||
"build-example": "npm install --no-save --ignore-scripts grunt grunt-cli gulp through2",
|
"build-example": "npm install --no-save --ignore-scripts grunt grunt-cli gulp through2",
|
||||||
"example": "cd example && node standalone.js && grunt markdownlint --force && gulp markdownlint"
|
"example": "cd example && node standalone.js && grunt markdownlint --force && gulp markdownlint",
|
||||||
|
"clone-test-repos": "make-dir test-repos && cd test-repos && git clone https://github.com/eslint/eslint eslint-eslint --depth 1 --no-tags --quiet && git clone https://github.com/mkdocs/mkdocs mkdocs-mkdocs --depth 1 --no-tags --quiet && git clone https://github.com/pi-hole/docs pi-hole-docs --depth 1 --no-tags --quiet",
|
||||||
|
"clone-test-repos-large": "npm run clone-test-repos && cd test-repos && git clone https://github.com/dotnet/docs dotnet-docs --depth 1 --no-tags --quiet",
|
||||||
|
"lint-test-repos": "node test/markdownlint-test-repos.js",
|
||||||
|
"clean-test-repos": "rimraf test-repos"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
|
|
@ -3352,18 +3384,20 @@ module.exports={
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "~13.11.1",
|
"@types/node": "~13.11.1",
|
||||||
"browserify": "~16.5.1",
|
"browserify": "~16.5.1",
|
||||||
"c8": "~7.1.0",
|
"c8": "~7.1.2",
|
||||||
"cpy-cli": "~3.1.0",
|
"cpy-cli": "~3.1.0",
|
||||||
"eslint": "~6.8.0",
|
"eslint": "~6.8.0",
|
||||||
"eslint-plugin-jsdoc": "~22.1.0",
|
"eslint-plugin-jsdoc": "~22.1.0",
|
||||||
"glob": "~7.1.6",
|
"globby": "~11.0.0",
|
||||||
"js-yaml": "~3.13.1",
|
"js-yaml": "~3.13.1",
|
||||||
|
"make-dir-cli": "~2.0.0",
|
||||||
"markdown-it-for-inline": "~0.1.1",
|
"markdown-it-for-inline": "~0.1.1",
|
||||||
"markdown-it-katex": "~2.0.3",
|
"markdown-it-katex": "~2.0.3",
|
||||||
"markdown-it-sub": "~1.0.0",
|
"markdown-it-sub": "~1.0.0",
|
||||||
"markdown-it-sup": "~1.0.0",
|
"markdown-it-sup": "~1.0.0",
|
||||||
"markdownlint-rule-helpers": "~0.7.0",
|
"markdownlint-rule-helpers": "~0.7.0",
|
||||||
"rimraf": "~3.0.2",
|
"rimraf": "~3.0.2",
|
||||||
|
"strip-json-comments": "~3.1.0",
|
||||||
"tape": "~4.13.2",
|
"tape": "~4.13.2",
|
||||||
"tape-player": "~0.1.0",
|
"tape-player": "~0.1.0",
|
||||||
"toml": "~3.0.0",
|
"toml": "~3.0.0",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "markdownlint-rule-helpers",
|
"name": "markdownlint-rule-helpers",
|
||||||
"version": "0.9.0",
|
"version": "0.10.0",
|
||||||
"description": "A collection of markdownlint helper functions for custom rules",
|
"description": "A collection of markdownlint helper functions for custom rules",
|
||||||
"main": "helpers.js",
|
"main": "helpers.js",
|
||||||
"author": "David Anson (https://dlaa.me/)",
|
"author": "David Anson (https://dlaa.me/)",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "markdownlint",
|
"name": "markdownlint",
|
||||||
"version": "0.20.2",
|
"version": "0.20.3",
|
||||||
"description": "A Node.js style checker and lint tool for Markdown/CommonMark files.",
|
"description": "A Node.js style checker and lint tool for Markdown/CommonMark files.",
|
||||||
"main": "lib/markdownlint.js",
|
"main": "lib/markdownlint.js",
|
||||||
"types": "lib/markdownlint.d.ts",
|
"types": "lib/markdownlint.d.ts",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue