JavaScript syntax highlighter
uploaded: 27th June 2k6
JavaScript is required for the text-parser to work.
A syntax parser for JavaScript code. All occurrences of the symbols: <, >, " and & are replaced with character entities. then the syntax is highlighted. No checks are made for valid code.
CSS
Highlight colours are defined by:
<style type="text/css">
span.comment {color:#060; font-weight:normal}
span.oper {color:#006; font-weight:normal}
span.var {color:#600; font-weight:normal}
span.func {color:#606; font-weight:normal}
span.num {color:#300; font-weight:bold}
span.string {color:#066; font-weight:normal}
span.reg {color:#666; font-weight:normal}
</style>
Credits
- Function addEvent()
- The usual onload handler from Simon Willison
- Function syntaxHighlight()
- A vaguely modified version of Syntax highlighter for JavaScript 1.2 from howtocreate.co.uk