Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diff + language does not work in combination with autoloader #2577

Closed
asaaki opened this issue Oct 7, 2020 · 0 comments · Fixed by #2580
Closed

diff + language does not work in combination with autoloader #2577

asaaki opened this issue Oct 7, 2020 · 0 comments · Fixed by #2580

Comments

@asaaki
Copy link

asaaki commented Oct 7, 2020

Information:

  • Prism version: 1.21 (from download page)
  • Plugins: line-numbers, autolinker, highlight-keywords, previewers, autoloader, keep-markup, unescaped-markup, normalize-whitespace, data-uri-highlight, diff-highlight
  • Environment: Browser

Description

When using autoloader the following snippets under example won't be correctly highlighted and prism tries to load an invalid grammar file.

GET <redacted>/prism-diff-javascript.min.js net::ERR_ABORTED 404 (Not Found)

Which makes sense in general, as there are no grammars with the pattern prism-diff-{language}.min.js.

Without autoloader plugin and the languages bundled in it does work.

Example

<pre><code class="language-diff-javascript">
@@ -4,6 +4,5 @@
-    let foo = bar.baz([1, 2, 3]);
-    foo = foo + 1;
+    const foo = bar.baz([1, 2, 3]) + 1;
     console.log(`foo: ${foo}`);
</code></pre>
<pre><code class="language-diff-javascript diff-highlight">
@@ -4,6 +4,5 @@
-    let foo = bar.baz([1, 2, 3]);
-    foo = foo + 1;
+    const foo = bar.baz([1, 2, 3]) + 1;
     console.log(`foo: ${foo}`);
</code></pre>

(see examples on https://prismjs.com/plugins/diff-highlight/)

Both snippets won't be hightlighted as the needed individual grammars won't be loaded.

Also using data-dependencies does not solve the problem:

<pre><code class="language-diff-javascript" data-dependencies="diff,javascript">
@@ -4,6 +4,5 @@
-    let foo = bar.baz([1, 2, 3]);
-    foo = foo + 1;
+    const foo = bar.baz([1, 2, 3]) + 1;
     console.log(`foo: ${foo}`);
</code></pre>

It might load the grammars, but then still does not highlight the code at all (neither diff nor javascript).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants