Please consider donating to help support development .

It is completely themable via CSS.

It was designed to be lightweight (2.5kb) , easy to use, and extendable.

Rainbow is a code syntax highlighting library written in Javascript.

How do I use it?

1. First include some markup for code you want to be highlighted.

Rainbow will pick up the language based on the data-language attribute. This example shows you how to display python code.

<pre><code data-language="python">def openFile(path): file = open(path, "r") content = file.read() file.close() return content</code></pre>

If you want to highlight HTML you should change data-language="python" to data-language="html" .

You can see the list of supported languages here.

2. Then include a css theme file in the <head> of your page

<link href="/assets/css/theme.css" rel="stylesheet" type="text/css">

3. Finally include rainbow js and whatever language(s) you want before the closing </body> tag.

<script src="/assets/js/rainbow.js"></script> <script src="/assets/js/language/generic.js"></script> <script src="/assets/js/language/python.js"></script>

Node.js

If you are using node.js you can install rainbow from NPM.

npm install rainbow-code

Then use it