microlight.js

Created: — modified: — tags: javascript links

a 2.2k library to hilight any code

Today I learned about existence of microlight.js (archived version) - a small library to hilight any code.

Of course, it has some bugs and incompatibilities with Bash - like, it has a list of keywords, among which is "from" (it's a keyword in some languages), and it highlights it in rsync --exclude-from=/file/name. Or, it has a simple regexp detector, which considers everything between forward slashes to be an regexp. So if you put a UNIX path somewhere outside the quotes - then it will hilight it like an regexp, like in the example above.

But what did you expect from a 2.2k library? Language detection?!

I'm actually using a modified version by WolfieZero, which adds classes instead of hardcoded styles (because I think that styles implemented by original author are not very good for white background), and modified it a bit further to use querySelectorAll function instead of getElementsByClassName and to act by default on all <code> elements (to make it out-of-the-box-compatible with markdown-generated markup)

My modified version should appear below: