@11ty/eleventy-plugin-syntaxhighlight
Advanced tools
Comparing version 3.0.1 to 3.0.2
{ | ||
"name": "@11ty/eleventy-plugin-syntaxhighlight", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "A pack of Eleventy plugins for syntax highlighting for Markdown and Liquid templates.", | ||
@@ -11,3 +11,4 @@ "publishConfig": { | ||
"test": "npx ava", | ||
"demo": "npx @11ty/eleventy --input=demo --output=demo/_site --config=demo/eleventy-config.js" | ||
"demo": "npx @11ty/eleventy --input=demo --output=demo/_site --config=demo/eleventy-config.js", | ||
"start": "npx @11ty/eleventy --input=demo --output=demo/_site --config=demo/eleventy-config.js --serve" | ||
}, | ||
@@ -40,4 +41,4 @@ "repository": { | ||
"devDependencies": { | ||
"ava": "^2.4.0", | ||
"@11ty/eleventy": "^0.9.0" | ||
"@11ty/eleventy": "^0.10.0", | ||
"ava": "^3.5.0" | ||
}, | ||
@@ -44,0 +45,0 @@ "dependencies": { |
@@ -6,7 +6,12 @@ const Prism = require("prismjs"); | ||
module.exports = function(content, language, highlightNumbers, options = {}) { | ||
// default to on | ||
if(options.trim === undefined || options.trim === true) { | ||
content = content.trim(); | ||
} | ||
let highlightedContent; | ||
if( language === "text" ) { | ||
highlightedContent = content.trim(); | ||
highlightedContent = content; | ||
} else { | ||
highlightedContent = Prism.highlight(content.trim(), PrismLoader(language), language); | ||
highlightedContent = Prism.highlight(content, PrismLoader(language), language); | ||
} | ||
@@ -13,0 +18,0 @@ |
@@ -1,3 +0,3 @@ | ||
import test from "ava"; | ||
import hasTemplateFormat from "../src/hasTemplateFormat"; | ||
const test = require("ava"); | ||
const hasTemplateFormat = require("../src/hasTemplateFormat"); | ||
@@ -4,0 +4,0 @@ test("hasTemplateFormats", t => { |
@@ -1,3 +0,3 @@ | ||
import test from "ava"; | ||
import HighlightLinesGroup from "../src/HighlightLinesGroup"; | ||
const test = require("ava"); | ||
const HighlightLinesGroup = require("../src/HighlightLinesGroup"); | ||
@@ -4,0 +4,0 @@ test("Empty", t => { |
@@ -1,3 +0,3 @@ | ||
import test from "ava"; | ||
import HighlightLines from "../src/HighlightLines"; | ||
const test = require("ava"); | ||
const HighlightLines = require("../src/HighlightLines"); | ||
@@ -4,0 +4,0 @@ test("HighlightLines empty", t => { |
@@ -1,3 +0,3 @@ | ||
import test from "ava"; | ||
import HighlightPairedShortcode from "../src/HighlightPairedShortcode"; | ||
const test = require("ava"); | ||
const HighlightPairedShortcode = require("../src/HighlightPairedShortcode"); | ||
@@ -57,3 +57,15 @@ test("Base", async t => { | ||
await HighlightPairedShortcode("", "asldkjflksdaj"); | ||
}) | ||
}); | ||
}); | ||
test("Trim content option (defaults true)", async t => { | ||
t.is(await HighlightPairedShortcode(` alert(); | ||
alert(); `, "js", "", {}), `<pre class="language-js"><code class="language-js"><span class="token function">alert</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span><br><span class="token function">alert</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>`); | ||
t.is(await HighlightPairedShortcode(` alert(); | ||
alert(); `, "js", "", { trim: true }), `<pre class="language-js"><code class="language-js"><span class="token function">alert</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span><br><span class="token function">alert</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>`); | ||
t.is(await HighlightPairedShortcode(` alert(); | ||
alert(); `, "js", "", { trim: false }), `<pre class="language-js"><code class="language-js"> <span class="token function">alert</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span><br><span class="token function">alert</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> </code></pre>`); | ||
}); |
@@ -1,4 +0,4 @@ | ||
import test from "ava"; | ||
import md from "markdown-it"; | ||
import markdownPrismJsOptions from "../src/markdownSyntaxHighlightOptions"; | ||
const test = require("ava"); | ||
const md = require("markdown-it"); | ||
const markdownPrismJsOptions = require("../src/markdownSyntaxHighlightOptions"); | ||
@@ -5,0 +5,0 @@ test("Test Markdown Highlighter", t => { |
51422
818