Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

@11ty/eleventy-plugin-syntaxhighlight

Package Overview
Dependencies
1
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.1 to 2.0.2

test/MarkdownHighlightTest.js

2

package.json
{
"name": "@11ty/eleventy-plugin-syntaxhighlight",
"version": "2.0.1",
"version": "2.0.2",
"description": "A pack of Eleventy plugins for syntax highlighting for Markdown and Liquid templates.",

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

@@ -30,2 +30,25 @@ const HighlightLines = require("./HighlightLines");

splitLineMarkup(line, before, after) {
let startCount = line.split("<span").length;
let endCount = line.split("</span").length;
if( startCount > endCount ) {
if( startCount === 2 ) { // simple cases, one orphan <span>
let split = line.split(">");
let first = split.shift();
return first + ">" + before + split.join(">") + after;
}
return line;
} else if( endCount > startCount ) {
if( endCount === 2 ) { // simple cases, one orphan </span>
let split = line.split("</");
let last = split.pop();
return before + split.join("</") + after + "</" + last;
}
return line;
}
return before + line + after;
}
getLineMarkup(lineNumber, line, extraClasses = []) {

@@ -35,12 +58,12 @@ let extraClassesStr = (extraClasses.length ? " " + extraClasses.join(" ") : "");

if (this.isHighlighted(lineNumber)) {
return `<mark class="highlight-line highlight-line-active${extraClassesStr}">${line}</mark>`;
return this.splitLineMarkup(line, `<mark class="highlight-line highlight-line-active${extraClassesStr}">`, `</mark>`);
}
if (this.isHighlightedAdd(lineNumber)) {
return `<ins class="highlight-line highlight-line-add${extraClassesStr}">${line}</ins>`;
return this.splitLineMarkup(line, `<ins class="highlight-line highlight-line-add${extraClassesStr}">`, `</ins>`);
}
if (this.isHighlightedRemove(lineNumber)) {
return `<del class="highlight-line highlight-line-remove${extraClassesStr}">${line}</del>`;
return this.splitLineMarkup(line, `<del class="highlight-line highlight-line-remove${extraClassesStr}">`, `</del>`);
}
return `<span class="highlight-line${extraClassesStr}">${line}</span>`;
return this.splitLineMarkup( line, `<span class="highlight-line${extraClassesStr}">`, `</span>`);
}

@@ -47,0 +70,0 @@ }

@@ -1,2 +0,1 @@

const HighlightLinesGroup = require("./HighlightLinesGroup");
const HighlightPairedShortcode = require("./HighlightPairedShortcode");

@@ -3,0 +2,0 @@

@@ -79,1 +79,9 @@ import test from "ava";

});
test("Split Line Markup", t => {
let hilite = new HighlightLinesGroup("", " ");
t.is(hilite.splitLineMarkup("Test", "BEFORE", "AFTER"), "BEFORETestAFTER");
t.is(hilite.splitLineMarkup("<span>Test</span>", "BEFORE", "AFTER"), "BEFORE<span>Test</span>AFTER");
t.is(hilite.splitLineMarkup("<span>Test", "BEFORE", "AFTER"), "<span>BEFORETestAFTER");
t.is(hilite.splitLineMarkup("Test</span>", "BEFORE", "AFTER"), "BEFORETestAFTER</span>");
});
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc