chickadee » colorize

colorize

Description

Colorize programming code as HTML (syntax highlighting).

Author

Brian Mastenbrook, ported to Chicken by Peter Bex

Documentation

This extension is a port of lisppaste's colorizing code. It currently supports syntax highlighting for the following languages:

Colorizing procedures

(coloring-type-names) procedure

Returns an alist of supported coloring types (recognised languages). The keys of this list are simple symbols which encode the internal name of the colorizer, the values of this list are human-readable strings describing the language.

(coloring-type-exists? name) procedure

If you don't need to know the name of a coloring type, this is a faster way to check if a given coloring type exists. name is a symbol which encodes the internal name of the coloring type. If the coloring type with that name exists, #t is returned, #f otherwise.

(html-colorize coloring-type string) procedure

Colorize the given string with the named coloring-type.

(use colorize)

(html-colorize 'c "int main(void) {\n    return 1;\n}")
 => "<span class=\"symbol\">int</span> main<span class=\"paren1\">(<span class=\"default\"><span class=\"symbol\">void</span></span>)</span> <span class=\"paren1\">{<span class=\"default\">\n    <span class=\"symbol\">return</span> 1;\n</span>}</span>"

Used CSS classes

The HTML can be easily and extensively styled using CSS. The colorizers use the following classes:

Changelog

License

 Copyright (c) 2010-2012 Peter Bex
 Copyright (c) 2003-2010 Brian Mastenbrook
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
 "Software"), to deal in the Software without restriction, including
 without limitation the rights to use, copy, modify, merge, publish,
 distribute, sublicense, and/or sell copies of the Software, and to
 permit persons to whom the Software is furnished to do so, subject to
 the following conditions:
 
 The above copyright notice and this permission notice shall be
 included in all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contents »