| Script Summary: Highlights the syntax in the text of 'code' tags according to a best-fit guess to determine language from 11 different languages. |
this script has 1 topic, 9 posts |
This script has no reviews. |
This script will highlight syntax in a wide variety of languages. It will only operate on text in 'code' tags, and uses a 'best fit' guess to determine the language based on the number of syntax elements it matches. It will not attempt to highlight 'code' tags with the attribute class="no-highlight".
Only HTML and CSS are active by default, but changing the first executable line will allow you to highlight any combination of the following:
- python
- html
- css
- delphi
- perl
- php
- java
- cpp
- ruby
- javascript
- vbscript
The highlighting is done via CSS, which is placed for your convenience at the top of the script.
Test HTML can be found at http://pastebin.ca/399719 (and I apologize that I lack the ability to host the HTML file myself). Copy and paste it into notepad (or equivalent) and save it, then open with firefox. Again, sorry for the inconvenience.
I recieved the idea for this script from the thread http://userscripts.org/forums/2/topics/84 and the vast majority of the script, in all fairness, was written by Ivan Sagalaev and his collaborators (referred to in the thread). The original script is available at http://softwaremaniacs.org/soft/highlight/ under a BSD license. The two non-superficial additions in the grease monkey version of the script are calling the initialization function and adding the CSS directly (in the original, the CSS was in the test HTML, not in the script itself).
Change Log:
YYYY/MM/DD comment
2007/03/22 Fixed line wrapping error
2007/03/18 Initial script creation