Code-lighter is a light-weight syntax highlight plugin.
It was written in pure javascript, and no dependcies for other library. It has two themes now and you can custmize your own style. Code-lighter uses a method by parsing and analysing the code and has more accurate then those that using Regex. Currently the language supported are:
Of course, you can join us and add support for more language.
First wrap the code using <pre> tag.
<pre> <div id='js'> // comment line function bar(){ var foo = 'hello'; var number = 5 * 6 / 20; return foo; } var id = document.getElementById('id'); window.onload = function() {alert('hello world');}; </div> </pre>
then run
var code = lighter.code({
target:document.getElementById('js'),
language:'javascript'
});
now using code.on() or code.off() to turn on/off the highlight.
var code = lighter.code({
target:document.getElementById('js'),
language:'javascript',
style:'dark'
});
// comment line function bar(){ var foo = 'hello'; var number = 5 * 6 / 20; return foo; } var id = document.getElementById('id'); window.onload = function() {alert('hello world');};
var code = lighter.code({
target:document.getElementById('js'),
language:'javascript',
style:'light'
});
// comment line function bar(){ var foo = 'hello'; var number = 5 * 6 / 20; return foo; } var id = document.getElementById('id'); window.onload = function() {alert('hello world');};
var code = lighter.code({
target:document.getElementById('js'),
language:'javascript',
style:'light'
lineSpace:4
lineNumber:false
});
The code is under MIT Lisense.
This project is maintained by icymorn