Common Lisp Package: COLORIZE

Homepage: <a href="http://github.com/redline6561/colorize">Github</a>

README:

colorize colorize is a lisp library for syntax highlighting supporting the following languages:

  • Common Lisp, :common-lisp
  • Emacs Lisp, :elisp
  • Scheme, :scheme
  • Clojure, :clojurealpha
  • C, :c
  • C++, :c++
  • Java, :java
  • Python, :python
  • Erlang, :erlang
  • Haskell, :haskell
  • Objective-C, :objective-c
  • Diff, :diff
  • Webkit, :webkit

Install You are strongly encouraged to use this library via Quicklisp. Simply start your lisp and run: (ql:quickload 'colorize).

Getting Started The API has three main entry points:

  1. COLORIZE-FILE which takes a language keyword and input file and writes the result to an html file in the same directory. An alternate path for the output file may be provided as a third argument.
  2. COLORIZE-FILE-TO-STREAM takes a keyword indicating the language, the path of a file to color, and a stream to write the result to. By default, it writes a complete self-contained page but if the :wrap keyword is given nil it only writes the colorized code snippet.
  3. HTML-COLORIZATION takes a keyword indicating the language and a string of code and returns the colorized html.

In addition, the COLORING-TYPES function takes no arguments and returns a list of the supported coloring types as keywords. Finally, the variable COLORING-CSS returns suggested css code for highlighting the produced html.

That's all for now. And remember, patches welcome!

FUNCTION

Public

COLORING-TYPES

Return the supported coloring types as a list of dotted pairs of the form, (:keyword . "coloring-type").

COLORIZE-FILE (COLORING-TYPE INPUT-FILE-NAME &OPTIONAL OUTPUT-FILE-NAME)

Given a COLORING-TYPE (keyword) and an INPUT-FILE-NAME, write colorized code to INPUT-FILE-NAME.html or OUTPUT-FILE-NAME, if provided.

COLORIZE-FILE-TO-STREAM (COLORING-TYPE INPUT-FILE-NAME STREAM &KEY (WRAP T) (CSS-BACKGROUND default) (ENCODER 'ENCODE-FOR-PRE))

Given a COLORING-TYPE, INPUT-FILE-NAME, and a STREAM to write to, output the colorized code to the given STREAM. If WRAP is nil, write only the HTML for the code snippet. To wrap in a <tt> element rather than <pre>, pass 'encode-for-tt as the ENCODER.

HTML-COLORIZATION (COLORING-TYPE STRING &OPTIONAL (ENCODER 'ENCODE-FOR-PRE))

Given a COLORING-TYPE and STRING, return the colorized HTML.

Undocumented

AUTODETECT-COLORING-TYPE (NAME)

FIND-COLORING-TYPE (TYPE)

SETFFIND-COLORING-TYPE (NEW-VALUE TYPE)

FORMAT-SCAN (COLORING-TYPE SCAN)

MAKE-BACKGROUND-CSS (COLOR &KEY (CLASS *CSS-BACKGROUND-CLASS*) (EXTRA NIL))

SCAN-STRING (COLORING-TYPE STRING)

Private

Undocumented

FOR-CSS (THING)

FULL-TRANSITION-TABLE (COLORING-TYPE-OBJECT)

MACRO

Private

Undocumented

DEFINE-COLORING-TYPE (NAME FANCY-NAME &KEY DEFAULT-MODE TRANSITIONS FORMATTERS AUTODETECT PARENT FORMATTER-VARIABLES (FORMATTER-AFTER-HOOK '(CONSTANTLY )) INVISIBLE)

WITH-GENSYMS ((&REST NAMES) &BODY BODY)

WITH-SCANNING-FUNCTIONS (STRING-PARAM POSITION-PLACE MODE-PLACE MODE-WAIT-PLACE &BODY BODY)

SLOT-ACCESSOR

Private

Undocumented

COLORING-TYPE-AUTODETECT-FUNCTION (OBJECT)

SETFCOLORING-TYPE-AUTODETECT-FUNCTION (NEW-VALUE OBJECT)

COLORING-TYPE-DEFAULT-MODE (OBJECT)

SETFCOLORING-TYPE-DEFAULT-MODE (NEW-VALUE OBJECT)

COLORING-TYPE-FANCY-NAME (OBJECT)

SETFCOLORING-TYPE-FANCY-NAME (NEW-VALUE OBJECT)

COLORING-TYPE-FORMATTER-AFTER-HOOK (OBJECT)

SETFCOLORING-TYPE-FORMATTER-AFTER-HOOK (NEW-VALUE OBJECT)

COLORING-TYPE-FORMATTER-INITIAL-VALUES (OBJECT)

SETFCOLORING-TYPE-FORMATTER-INITIAL-VALUES (NEW-VALUE OBJECT)

COLORING-TYPE-PARENT-TYPE (OBJECT)

SETFCOLORING-TYPE-PARENT-TYPE (NEW-VALUE OBJECT)

COLORING-TYPE-TERM-FORMATTER (OBJECT)

SETFCOLORING-TYPE-TERM-FORMATTER (NEW-VALUE OBJECT)

COLORING-TYPE-TRANSITION-FUNCTIONS (OBJECT)

SETFCOLORING-TYPE-TRANSITION-FUNCTIONS (NEW-VALUE OBJECT)

COLORING-TYPE-VISIBLE (OBJECT)

SETFCOLORING-TYPE-VISIBLE (NEW-VALUE OBJECT)

VARIABLE

Public

Undocumented

*COLORING-CSS*

*CSS-BACKGROUND-CLASS*

*VERSION-TOKEN*

Private

Undocumented

*C++-RESERVED-WORDS*

*C-BEGIN-WORD*

*C-CLOSE-PARENS*

*C-OPEN-PARENS*

*C-RESERVED-WORDS*

*C-TERMINATORS*

*CLOSE-PARENS*

*COLORING-TYPES*

*COMMON-MACROS*

*ERLANG-BEGIN-FUN*

*ERLANG-BEGIN-VAR*

*ERLANG-BEGIN-WORD*

*ERLANG-CLOSE-PARENS*

*ERLANG-OPEN-PARENS*

*ERLANG-RESERVED-WORDS*

*ERLANG-TERMINATORS*

*HASKELL-BEGIN-CONS*

*HASKELL-BEGIN-ID*

*HASKELL-CLOSE-PARENS*

*HASKELL-IN-SYMBOL*

*HASKELL-IN-WORD*

*HASKELL-NON-CONSTITUENT*

*HASKELL-OPEN-PARENS*

*HASKELL-RESERVED-SYMBOLS*

*HASKELL-RESERVED-WORDS*

*JAVA-RESERVED-WORDS*

*NON-CONSTITUENT*

*NUMBERS*

*OPEN-PARENS*

*PYTHON-RESERVED-WORDS*

*RESET-POSITION*

*SCAN-CALLS*

*SPECIAL-FORMS*

*SYMBOL-CHARACTERS*

CLASS

Private

Undocumented

COLORING-TYPE