Skip to content

Commit

Permalink
Fixes #76
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Apr 12, 2023
1 parent 150d1ad commit 1016319
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/PrismLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = function(language, options = {}) {
// aliasing should ignore diff-
let aliasedName = PrismAlias(diffRemovedRawName);

if(!Prism.languages[ aliasedName ]) {
if(!Prism.languages[ aliasedName ]) { // matches `diff` too
PrismLoader(aliasedName);
}

Expand All @@ -30,10 +30,11 @@ module.exports = function(language, options = {}) {

if(!Prism.languages.diff) {
PrismLoader("diff");
// Bundled Plugin
require("prismjs/plugins/diff-highlight/prism-diff-highlight");
}

// Bundled Plugin
require("prismjs/plugins/diff-highlight/prism-diff-highlight");

// Store into with aliased keys
// ts -> diff-typescript
// js -> diff-javascript
Expand Down
5 changes: 3 additions & 2 deletions test/11tyjs-diff/test.11ty.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = function(data) {
let result = this.highlight("diff-js", "-var test;");
return result;
let result1 = this.highlight("diff", "-var test;");
let result2 = this.highlight("diff-js", "-var test;");
return result1 + "\n" + result2;
};
3 changes: 2 additions & 1 deletion test/JavaScriptFunctionTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ test("JavaScript Function Diff", async t => {

t.is(json.length, 1);
let rendered = json[0].content;
t.is(`<pre class="language-diff-js"><code class="language-diff-js"><span class="token deleted-sign deleted language-js"><span class="token prefix deleted">-</span><span class="token keyword">var</span> test<span class="token punctuation">;</span></span></code></pre>`, rendered);
t.is(`<pre class="language-diff"><code class="language-diff"><span class="token deleted-sign deleted"><span class="token prefix deleted">-</span><span class="token line">var test;</span></span></code></pre>
<pre class="language-diff-js"><code class="language-diff-js"><span class="token deleted-sign deleted language-js"><span class="token prefix deleted">-</span><span class="token keyword">var</span> test<span class="token punctuation">;</span></span></code></pre>`, rendered);
});

0 comments on commit 1016319

Please sign in to comment.