ccampbell / rainbow

Simple syntax highlighting library written in javascript
http://rainbowco.de
Apache License 2.0
3.3k stars 465 forks source link

Javascript Highlighter seems to not work as expected #248

Closed Neohiro79 closed 4 years ago

Neohiro79 commented 4 years ago

Javscript won't work, weather with data-language="javascript" nor with class="language-javascript"

see this fiddle here:

http://jsfiddle.net/neohiro79/1grwjb50/27/

or am I missing something important here?

Also the style tags get some additional tabspace - is there a way to change this?

ccampbell commented 4 years ago

Javascript depends on the generic language patterns so you have to include that first. As for the style tags, <pre> blocks will format content exactly as it appears so it is probably a best practice to use spaces vs. tabs and unindent everything you want formatted.

This fork of your fiddle has it all working: https://jsfiddle.net/7kvcguez/

Neohiro79 commented 4 years ago

Thank you so much @ccampbell !!!

Neohiro79 commented 4 years ago

One more question:

Do I need to include generic.js above any other programming language except for HTML & CSS?

Or is the best way to do it like you described here:

If you want a minimized version with all languages you can pass

gulp build --languages=all

??

ccampbell commented 4 years ago

Certain languages depend on the generic patterns, but not all.

https://github.com/ccampbell/rainbow/blob/05892a8ebe7689ab3b9ab96cfc77414d8467e749/gulpfile.js#L86

The best bet is using gulp build to create a custom bundle and passing whatever languages you want in a list. You can also use the bundler from the rainbow website, but it is using a slightly out of date version of rainbow (long story) http://rainbowco.de

Neohiro79 commented 4 years ago

Thanx for that damn quick reply Craig! You're the best!!