New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rehype-highlight-code-lines

Package Overview
Dependencies
Maintainers
0
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rehype-highlight-code-lines - npm Package Compare versions

Comparing version

to
0.0.3

25

dist/esm/index.js

@@ -26,15 +26,16 @@ import { visit, CONTINUE } from "unist-util-visit";

const node = children[i];
console.log(node);
if (node.type !== "element") {
newTree = newTree.concat([node]);
}
else if (node.children.length === 1 && node.children[0].type !== "element") {
// @ts-expect-error
node.properties.className = className.concat(node.properties.className);
newTree = newTree.concat([node]);
}
else {
// @ts-expect-error
// /* v8 ignore next */
const classNames = className.concat(node.properties?.className || []);
newTree = newTree.concat(flattenCodeTree(node.children, classNames));
if (node.children.length === 1 && node.children[0].type !== "element") {
node.properties.className = classNames;
newTree = newTree.concat([node]);
}
else {
newTree = newTree.concat(flattenCodeTree(node.children, classNames));
}
}

@@ -159,5 +160,13 @@ }

}
if (settings.showLineNumbers) {
if (!meta) {
meta = "showlinenumbers";
}
else if (!meta.includes("showlinenumbers")) {
meta = meta + " showlinenumbers";
}
}
if (!meta)
return;
const showLineNumbers = settings.showLineNumbers || meta.includes("showlinenumbers");
const showLineNumbers = meta.includes("showlinenumbers");
// find number range string within curly braces and parse it

@@ -164,0 +173,0 @@ const RE = /{(?<lines>[\d\s,-]+)}/g;

{
"name": "rehype-highlight-code-lines",
"version": "0.0.2",
"version": "0.0.3",
"description": "Rehype plugin to add line numbers to code blocks and allow highlighting of desired code lines",

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

@@ -59,13 +59,15 @@ import type { Plugin } from "unified";

const node = children[i];
console.log(node);
if (node.type !== "element") {
newTree = newTree.concat([node]);
} else if (node.children.length === 1 && node.children[0].type !== "element") {
// @ts-expect-error
node.properties.className = className.concat(node.properties.className);
newTree = newTree.concat([node]);
} else {
// @ts-expect-error
// /* v8 ignore next */
const classNames = className.concat(node.properties?.className || []);
newTree = newTree.concat(flattenCodeTree(node.children, classNames));
if (node.children.length === 1 && node.children[0].type !== "element") {
node.properties.className = classNames;
newTree = newTree.concat([node]);
} else {
newTree = newTree.concat(flattenCodeTree(node.children, classNames));
}
}

@@ -226,5 +228,13 @@ }

if (settings.showLineNumbers) {
if (!meta) {
meta = "showlinenumbers";
} else if (!meta.includes("showlinenumbers")) {
meta = meta + " showlinenumbers";
}
}
if (!meta) return;
const showLineNumbers = settings.showLineNumbers || meta.includes("showlinenumbers");
const showLineNumbers = meta.includes("showlinenumbers");

@@ -231,0 +241,0 @@ // find number range string within curly braces and parse it

Sorry, the diff of this file is not supported yet