Highlight.js: No colors for `bash` and `shell`

Created on 13 Dec 2018  路  9Comments  路  Source: highlightjs/highlight.js

Attempted to create an example for bash and shell highlighting, but the latest version does not show any colors (grey background with black text): http://plnkr.co/edit/smWejiNw2dNd5QjrmZzm?p=preview

However, the highlight.js website shows colors somehow??

All 9 comments

Hi @ericis,
add the following

<script>hljs.initHighlightingOnLoad();</script>

after loading highlight.min.js.

Also some points:

  1. No need to load bash.min.js and shell.min.js as both of them are contained in highlight.min.js.
  2. No need to add hljs class; <pre><code class='bash'> is just fine.
  3. If the text to highlight starts with bash prompt ($), choose shell class. Otherwise, choose bash.

I'm closing this as there was no reply. Feel free to reopen in case something left unanswered.

For reference I actually had to load the shell language, in order to access the feature.

Highlight JS 10.1.1

"shell" is definitely included in the latest CDN builds:

https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js

Yes but I needed to load the language as well in order to have shell highlighting to kick in, maybe there's somthing wrong in my setup. Byt this goes over my competences in JS.

I don't see why that would be. Bash and Shell are both included in the default/common build - unless you're using a custom build without them. If you can reproduce a standalone jsfiddle that shows you issue you can file an issue and I'd be happy to take a look.

@yyyc514 I'll see what I can come up with tomorrow.

For simple tests you can fork https://jsfiddle.net/ajoshguy/2bmdswn6/4/

@yyyc514 It turns out I could not reproduce ; maybe I was too tired. After investigating... well indeed shell language works with the default build. It was a hugo template error in the theme. Thank you for the patience. I understand what it is to maintain an opensource project.

Cheers !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

goloroden picture goloroden  路  3Comments

zhouxy666 picture zhouxy666  路  3Comments

gskinner picture gskinner  路  4Comments

sumanstats picture sumanstats  路  5Comments

vladshcherbin picture vladshcherbin  路  5Comments