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

highlight.js emits warning if no language is set on source block #4263

Closed
mojavelinux opened this issue Mar 6, 2022 · 3 comments
Closed
Assignees
Labels
bug v2.0.18 Issues resolved in the 2.0.18 release
Milestone

Comments

@mojavelinux
Copy link
Member

mojavelinux commented Mar 6, 2022

If no language is specified on a source block, and the source-highlighter attribute is set to highlight.js, the highlight.js emits the following warning into the browser console:

Could not find the language 'none', did you forget to load/include a language module?
Falling back to no-highlight mode for this block.

Here's an example:

[source]
----
no lang
----

The warning happens because the language none is not mapped to plaintext. To fix it, either add the mapping for none or don't pass blocks with the language none to highlight.js.

@mojavelinux mojavelinux self-assigned this Mar 6, 2022
@mojavelinux mojavelinux added the bug label Mar 6, 2022
@mojavelinux mojavelinux added this to the v2.1.x milestone Mar 6, 2022
@mojavelinux
Copy link
Member Author

Backport the fix for this issue to the v2.0.x branch.

@mojavelinux
Copy link
Member Author

Another solution is to add the CSS class language-plaintext so that highlight.js resolves the language to plaintext, which is mapped.

<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-plaintext language-none hljs">no lang</code></pre>
</div>
</div>
</div>

@mojavelinux mojavelinux modified the milestones: v2.1.x, v2.0.x Sep 28, 2022
@mojavelinux
Copy link
Member Author

Resolved by d5c9ab5 and backported.

@mojavelinux mojavelinux added the v2.0.18 Issues resolved in the 2.0.18 release label Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug v2.0.18 Issues resolved in the 2.0.18 release
Projects
None yet
Development

No branches or pull requests

2 participants
@mojavelinux and others