How to use it
<!DOCTYPE html>
<html>
<head>
<title>highlighter test page</title>
<script src="code-highlighter.js"></script>
</head>
<body>
<div id="exampleCodeBlock">
<script>
function foo(){bar="foobar";}
</script>
</div>
<script>highlightCode('exampleCodeBlock','blueish green');</script>
</body>
<html>
- First you right click and download the script » upload it to your own server.
- (see line 4), you put a link to the script in the head of the document.
- Change the src to the path of the script if you put it in a different folder.
- (see line 7), you create a div with it's own unique ID for every code block.
- (see line 12), you trigger the script directly after the div, that way the highlighter does it's job while the page loads.
- highlightCode is the name of the function,
- 'exampleCodeBlock' is the name of the div and 'blueish green' is the name of the color set.
- The color sets are named: 'fire', 'purple blue', 'techno', 'restfull', 'contrast', 'gray shades', 'haxor green' and 'blueish green'.
- (see lines 8 and 10), you replace the smaller than < and bigger than > characters with < and > to prevent the browser from rendering it.