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

markdownlint-rule-helpers

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdownlint-rule-helpers - npm Package Compare versions

Comparing version 0.14.0 to 0.15.0

52

helpers.js

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

// Regular expression for inline links and shortcut reference links
const linkRe = /\[(?:[^[\]]|\[[^\]]*\])*\](?:\(\S*\))?/g;
const linkRe = /(\[(?:[^[\]]|\[[^\]]*\])*\])(\(\S*\)|\[\S*\])?/g;
module.exports.linkRe = linkRe;
// readFile options for reading with the UTF-8 encoding
module.exports.utf8Encoding = "utf8";
// Regular expression for link reference definition lines
module.exports.linkReferenceRe = /^ {0,3}\[[^\]]+]:\s.*$/;

@@ -306,3 +307,3 @@ // All punctuation characters (normal and full-width)

// Returns (nested) lists as a flat array (in order)
module.exports.flattenLists = function flattenLists(params) {
module.exports.flattenLists = function flattenLists(tokens) {
const flattenedLists = [];

@@ -314,3 +315,3 @@ const stack = [];

let lastWithMap = { "map": [ 0, 1 ] };
params.tokens.forEach((token) => {
tokens.forEach((token) => {
if (isMathBlock(token) && token.map[1]) {

@@ -525,2 +526,43 @@ // markdown-it-texmath plugin does not account for math_block_end

/**
* Returns an array of code span ranges.
*
* @param {string[]} lines Lines to scan for code span ranges.
* @returns {number[][]} Array of ranges (line, index, length).
*/
module.exports.inlineCodeSpanRanges = (lines) => {
const exclusions = [];
forEachInlineCodeSpan(
lines.join("\n"),
(code, lineIndex, columnIndex) => {
const codeLines = code.split(newLineRe);
// eslint-disable-next-line unicorn/no-for-loop
for (let i = 0; i < codeLines.length; i++) {
exclusions.push(
[ lineIndex + i, columnIndex, codeLines[i].length ]
);
columnIndex = 0;
}
}
);
return exclusions;
};
/**
* Determines whether the specified range overlaps another range.
*
* @param {number[][]} ranges Array of ranges (line, index, length).
* @param {number} lineIndex Line index to check.
* @param {number} index Index to check.
* @param {number} length Length to check.
* @returns {boolean} True iff the specified range overlaps.
*/
module.exports.overlapsAnyRange = (ranges, lineIndex, index, length) => (
!ranges.every((span) => (
(lineIndex !== span[0]) ||
(index + length < span[1]) ||
(index > span[1] + span[2])
))
);
// Returns a range object for a line by applying a RegExp

@@ -527,0 +569,0 @@ module.exports.rangeFromRegExp = function rangeFromRegExp(line, regexp) {

2

package.json
{
"name": "markdownlint-rule-helpers",
"version": "0.14.0",
"version": "0.15.0",
"description": "A collection of markdownlint helper functions for custom rules",

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

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