Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

markdownlint

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdownlint - npm Package Compare versions

Comparing version 0.26.1 to 0.26.2

15

doc/Rules.md

@@ -1318,3 +1318,3 @@ # Rules

Note: To allow specific HTML elements, use the 'allowed_elements' parameter.
Note: To allow specific HTML elements, use the `allowed_elements` parameter.

@@ -2079,2 +2079,4 @@ Rationale: Raw HTML is allowed in Markdown, but this rule is included for

Parameters: ignored_definitions (array of string; default [ "//" ])
Fixable: Most violations can be fixed by tooling

@@ -2097,5 +2099,14 @@

This rule considers a reference definition to be used if any link or image
reference has the corresponding label. "Full", "collapsed", and "shortcut"
reference has the corresponding label. The "full", "collapsed", and "shortcut"
formats are all supported.
If there are reference definitions that are deliberately unreferenced, they can
be ignored by setting the `ignored_definitions` parameter. The default value of
this parameter ignores the following convention for adding non-HTML comments to
Markdown:
```md
[//]: # (This behaves like a comment)
```
<!-- markdownlint-configure-file {

@@ -2102,0 +2113,0 @@ "no-inline-html": {

60

helpers/helpers.js

@@ -33,5 +33,9 @@ // @ts-check

// Regular expression for reference links (full and collapsed but not shortcut)
// Regular expression for blockquote prefixes
const blockquotePrefixRe = /^[>\s]*/;
module.exports.blockquotePrefixRe = blockquotePrefixRe;
// Regular expression for reference links (full, collapsed, and shortcut)
const referenceLinkRe =
/!?\\?\[((?:\[[^\]\0]*]|[^\]\0])*)](?:(?:\[([^\]\0]*)\])|[^(]|$)/g;
/!?\\?\[((?:\[[^\]\0]*]|[^\]\0])*)](?:(?:\[([^\]\0]*)\])|([^(])|$)/g;

@@ -789,3 +793,3 @@ // Regular expression for link reference definitions

const excluded = (match) => withinAnyRange(
exclusions, 0, match.index, match[0].length
exclusions, 0, match.index, match[0].length - (match[3] || "").length
);

@@ -799,2 +803,3 @@ // Convert input to single-line so multi-line links/images are easier

if (!inCode) {
line = line.replace(blockquotePrefixRe, "");
if (line.trim().length === 0) {

@@ -851,4 +856,3 @@ // Allow RegExp to detect the end of a block

!(matchLabel || "").endsWith("\\") &&
(topLevel || matchString.startsWith("!")) &&
!excluded(referenceLinkMatch)
!(topLevel && excluded(referenceLinkMatch))
) {

@@ -862,18 +866,18 @@ const shortcutLink = (matchLabel === undefined);

if (label.length > 0) {
const referenceindex = referenceLinkMatch.index;
if (topLevel) {
// Calculate line index
while (lineOffsets[lineIndex + 1] <= referenceindex) {
lineIndex++;
}
} else {
// Use provided line index
lineIndex = contentLineIndex;
}
const referenceIndex = referenceindex +
(topLevel ? -lineOffsets[lineIndex] : contentIndex);
if (shortcutLink) {
// Track, but don't validate due to ambiguity: "text [text] text"
// Track separately due to ambiguity in "text [text] text"
shortcuts.add(label);
} else {
const referenceindex = referenceLinkMatch.index;
if (topLevel) {
// Calculate line index
while (lineOffsets[lineIndex + 1] <= referenceindex) {
lineIndex++;
}
} else {
// Use provided line index
lineIndex = contentLineIndex;
}
const referenceIndex = referenceindex +
(topLevel ? -lineOffsets[lineIndex] : contentIndex);
// Track reference and location

@@ -887,14 +891,12 @@ const referenceData = references.get(label) || [];

references.set(label, referenceData);
// Check for images embedded in top-level link text
if (!matchString.startsWith("!")) {
pendingContents.push(
{
"content": matchText,
"contentLineIndex": lineIndex,
"contentIndex": referenceIndex + 1,
"topLevel": false
}
);
}
}
// Check for links embedded in brackets
if (!matchString.startsWith("!")) {
pendingContents.push({
"content": matchText,
"contentLineIndex": lineIndex,
"contentIndex": referenceIndex + 1,
"topLevel": false
});
}
}

@@ -901,0 +903,0 @@ }

{
"name": "markdownlint-rule-helpers",
"version": "0.17.1",
"version": "0.17.2",
"description": "A collection of markdownlint helper functions for custom rules",

@@ -5,0 +5,0 @@ "main": "./helpers.js",

@@ -7,2 +7,2 @@ // @ts-check

module.exports.homepage = "https://github.com/DavidAnson/markdownlint";
module.exports.version = "0.26.1";
module.exports.version = "0.26.2";

@@ -236,7 +236,2 @@ // @ts-check

}
// Adjust maps for math blocks
if (helpers.isMathBlock(token) && token.map[1]) {
// markdown-it-texmath plugin does not account for math_block_end
token.map[1]++;
}
// Update token metadata

@@ -243,0 +238,0 @@ if (token.map) {

@@ -5,7 +5,6 @@ // @ts-check

const { addErrorContext, isBlankLine } = require("../helpers");
const { addErrorContext, blockquotePrefixRe, isBlankLine } =
require("../helpers");
const { flattenedLists } = require("./cache");
const quotePrefixRe = /^[>\s]*/;
module.exports = {

@@ -22,3 +21,3 @@ "names": [ "MD032", "blanks-around-lists" ],

const line = lines[firstIndex];
const quotePrefix = line.match(quotePrefixRe)[0].trimEnd();
const quotePrefix = line.match(blockquotePrefixRe)[0].trimEnd();
addErrorContext(

@@ -38,3 +37,3 @@ onError,

const line = lines[lastIndex];
const quotePrefix = line.match(quotePrefixRe)[0].trimEnd();
const quotePrefix = line.match(blockquotePrefixRe)[0].trimEnd();
addErrorContext(

@@ -41,0 +40,0 @@ onError,

@@ -41,3 +41,3 @@ // @ts-check

addError(onError, lineIndex + 1, "Element: " + element,
null, [ match.index + 1, tag.length ]);
undefined, [ match.index + 1, tag.length ]);
}

@@ -44,0 +44,0 @@ }

@@ -5,5 +5,5 @@ // @ts-check

const { addErrorContext, emphasisMarkersInContent, forEachLine, isBlankLine } =
require("../helpers");
const { lineMetadata } = require("./cache");
const { addErrorContext, emphasisMarkersInContent, forEachLine, isBlankLine,
withinAnyRange } = require("../helpers");
const { htmlElementRanges, lineMetadata } = require("./cache");

@@ -22,2 +22,3 @@ const emphasisRe = /(^|[^\\]|\\\\)(?:(\*\*?\*?)|(__?_?))/g;

"function": function MD037(params, onError) {
const exclusions = htmlElementRanges();
// eslint-disable-next-line init-declarations

@@ -55,21 +56,23 @@ let effectiveEmphasisLength, emphasisIndex, emphasisKind, emphasisLength,

const contextEnd = matchIndex + contextLength;
const context = line.substring(contextStart, contextEnd);
const column = contextStart + 1;
const length = contextEnd - contextStart;
const leftMarker = line.substring(contextStart, emphasisIndex);
const rightMarker = match ? (match[2] || match[3]) : "";
const fixedText = `${leftMarker}${content.trim()}${rightMarker}`;
return [
onError,
lineIndex + 1,
context,
leftSpace,
rightSpace,
[ column, length ],
{
"editColumn": column,
"deleteCount": length,
"insertText": fixedText
}
];
if (!withinAnyRange(exclusions, lineIndex, column, length)) {
const context = line.substring(contextStart, contextEnd);
const leftMarker = line.substring(contextStart, emphasisIndex);
const rightMarker = match ? (match[2] || match[3]) : "";
const fixedText = `${leftMarker}${content.trim()}${rightMarker}`;
return [
onError,
lineIndex + 1,
context,
leftSpace,
rightSpace,
[ column, length ],
{
"editColumn": column,
"deleteCount": length,
"insertText": fixedText
}
];
}
}

@@ -76,0 +79,0 @@ return null;

@@ -9,3 +9,4 @@ // @ts-check

// Regular expression for identifying HTML anchor names
const identifierRe = /(?:id|name)\s*=\s*['"]?([^'"\s>]+)/iu;
const idRe = /\sid\s*=\s*['"]?([^'"\s>]+)/iu;
const nameRe = /\sname\s*=\s*['"]?([^'"\s>]+)/iu;

@@ -59,7 +60,6 @@ /**

const [ tag, , element ] = match;
if (element.toLowerCase() === "a") {
const idMatch = identifierRe.exec(tag);
if (idMatch) {
fragments.set(`#${idMatch[1]}`, 0);
}
const anchorMatch = idRe.exec(tag) ||
(element.toLowerCase() === "a" && nameRe.exec(tag));
if (anchorMatch) {
fragments.set(`#${anchorMatch[1]}`, 0);
}

@@ -66,0 +66,0 @@ }

@@ -14,3 +14,4 @@ // @ts-check

"function": function MD053(params, onError) {
const { lines } = params;
const ignored = new Set(params.config.ignored_definitions || [ "//" ]);
const lines = params.lines;
const { references, shortcuts, definitions, duplicateDefinitions } =

@@ -27,3 +28,7 @@ referenceLinkImageData();

const [ label, lineIndex ] = definition;
if (!references.has(label) && !shortcuts.has(label)) {
if (
!ignored.has(label) &&
!references.has(label) &&
!shortcuts.has(label)
) {
const line = lines[lineIndex];

@@ -43,13 +48,15 @@ addError(

const [ label, lineIndex ] = duplicateDefinition;
const line = lines[lineIndex];
addError(
onError,
lineIndex + 1,
`Duplicate link or image reference definition: "${label}"`,
ellipsify(line),
[ 1, line.length ],
singleLineDefinition(line) ? deleteFixInfo : 0
);
if (!ignored.has(label)) {
const line = lines[lineIndex];
addError(
onError,
lineIndex + 1,
`Duplicate link or image reference definition: "${label}"`,
ellipsify(line),
[ 1, line.length ],
singleLineDefinition(line) ? deleteFixInfo : 0
);
}
}
}
};
{
"name": "markdownlint",
"version": "0.26.1",
"version": "0.26.2",
"description": "A Node.js style checker and lint tool for Markdown/CommonMark files.",

@@ -5,0 +5,0 @@ "type": "commonjs",

@@ -51,2 +51,3 @@ # markdownlint

* [Cake.Markdownlint addin for Cake build automation system](https://github.com/cake-contrib/Cake.Markdownlint)
* [Lombiq Node.js Extensions for MSBuild (.NET builds)](https://github.com/Lombiq/NodeJs-Extensions)
* Ruby

@@ -1024,2 +1025,3 @@ * [markdownlint/mdl gem for Ruby](https://rubygems.org/gems/mdl)

* 0.26.1 - Improve MD051.
* 0.26.2 - Improve MD037/MD051/MD053.

@@ -1026,0 +1028,0 @@ [npm-image]: https://img.shields.io/npm/v/markdownlint.svg

@@ -912,4 +912,20 @@ {

"description": "MD053/link-image-reference-definitions - Link and image reference definitions should be needed",
"type": "boolean",
"default": true
"type": [
"boolean",
"object"
],
"default": true,
"properties": {
"ignored_definitions": {
"description": "Ignored definitions",
"type": "array",
"items": {
"type": "string"
},
"default": [
"//"
]
}
},
"additionalProperties": false
},

@@ -916,0 +932,0 @@ "link-image-reference-definitions": {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc