colorize

Description

Author

Requirements

Documentation

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

Basic Lisp

Scheme

Emacs Lisp

Common Lisp

C

C++

Java

Objective C

Erlang

Python

Ruby

Haskell

Unified Context Diff

Colorizing procedures

[procedure](coloring-type-names)

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.

[procedure](html-colorize coloring-type string)

Colorize the given string with the named coloring-type.

Examples:

(use colorize)

(html-colorize 'c "int main(void) {\n return 1;\n}")

=>

"\">int main\">(\">\">void)\">{\">\n \">return 1;\n}"

Used CSS classes

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

comment for comments

character for character literals

string for string literals

variable for user variables that can be distinguished as such

function for function definitions if they can be distinguished as such (currently only used by the Erlang and Haskell coloring-types)

attribute for Erlang attributes

macro for macros (Erlang only)

atom for atoms (Erlang and Haskell only)

special for "special" variables. These include preprocessor directives in C, *starred-global-identifiers* for Lisps etc

symbol for symbols, identifiers, user variables that cannot be distinguished from regular symbols

Changelog

0.1 - Initial port

License

Copyright (c) 2010 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.