source: project/wiki/eggref/4/colorize @ 27195

Last change on this file since 27195 was 27195, checked in by sjamaan, 8 years ago

Update colorize changelog

File size: 5.0 KB
Line 
1[[tags: egg]]
2
3== colorize
4
5=== Description
6
7Colorize programming code as HTML (syntax highlighting).
8
9=== Author
10
11Brian Mastenbrook, ported to Chicken by [[/users/peter-bex|Peter Bex]]
12
13=== Documentation
14
15This extension is a port of
16[[http://www.common-lisp.net/project/lisppaste|lisppaste's]]
17colorizing code.  It currently supports syntax highlighting for the
18following languages:
19
20* Basic Lisp
21* Scheme
22* Emacs Lisp
23* Common Lisp
24* C
25* C++
26* Java
27* Objective C
28* Erlang
29* Python
30* Ruby
31* Haskell
32* Unified Context Diff
33* Cascading Style Sheets (CSS)
34* Extensible Markup Language (XML)
35* (Extensible) HyperText Markup Language ((X)HTML)
36
37=== Colorizing procedures
38
39<procedure>(coloring-type-names)</procedure>
40
41Returns an alist of supported coloring types (recognised languages).
42The keys of this list are simple symbols which encode the internal
43name of the colorizer, the values of this list are human-readable
44strings describing the language.
45
46<procedure>(coloring-type-exists? name)</procedure>
47
48If you don't need to know the name of a coloring type, this is a
49faster way to check if a given coloring type exists.  {{name}} is a
50symbol which encodes the internal name of the coloring type.  If the
51coloring type with that name exists, {{#t}} is returned, {{#f}} otherwise.
52
53<procedure>(html-colorize coloring-type string)</procedure>
54
55Colorize the given {{string}} with the named {{coloring-type}}.
56
57<enscript highlight="scheme">
58(use colorize)
59
60(html-colorize 'c "int main(void) {\n    return 1;\n}")
61 => "<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>"
62</enscript>
63
64=== Used CSS classes
65
66The HTML can be easily and extensively styled using CSS.
67The colorizers use the following classes:
68
69* {{comment}} for comments
70* {{character}} for character literals
71* {{string}} for string literals
72* {{variable}} for user variables that can be distinguished as such
73* {{function}} for function definitions if they can be distinguished as such (currently only used by the Erlang and Haskell coloring-types)
74* {{attribute}} for Erlang attributes
75* {{macro}} for macros (Erlang only)
76* {{atom}} for atoms (Erlang and Haskell only)
77* {{special}} for "special" variables.  These include preprocessor directives in C, {{*starred-global-identifiers*}} for Lisps etc
78* {{symbol}} for symbols, identifiers, user variables that cannot be distinguished from regular symbols
79* {{keyword}} for keyword types (actual keywords in Lisps, variables containing unusual characters in Haskell, etc)
80* {{paren1}} through {{paren6}} to indicate parenthetical nesting level
81* {{default}} to support displaying a different background of the code inside parens (for example to support mouse hover highlighting of matching parens)
82* {{syntax-error}} for syntax errors detected during parsing (currently unused)
83* {{diff-normal}} Lines of diff context without changes (Unified Diff only)
84* {{diff-added}} Added lines (Unified Diff only)
85* {{diff-deleted}} Deleted lines (Unified Diff only)
86
87=== Changelog
88
89* 0.4 - Do not rely on {{set!}}'s undefined return value.  Add some basic tests and try to lower compilation time by making the macro expansions less bulky.  Improve "keyword" detection in Scheme code. Add {{css}} and {{xml}} (with {{xhtml}} and {{html}} alias) colorizers.  Remove dependency on [[defstruct]].
90* 0.3.1 - Fix a potential bug in colorize setter code (thanks to [[/users/felix-winkelmann|Felix]])
91* 0.3 - Fix a few bugs in the Lisp colorizer that didn't always trigger in lisppaste's colorizer because it processes strings a line at a time(?)
92* 0.2.2 - More silly bugfixes
93* 0.2.1 - Fixed stupid bug caused by 0.2 and added {{coloring-type-exists?}} predicate
94* 0.2 - Ensured variables were not kept around in coloring type objects from previous invocations of html-colorize.
95* 0.1 - Initial port
96
97=== License
98
99  Copyright (c) 2010-2012 Peter Bex
100  Copyright (c) 2003-2010 Brian Mastenbrook
101 
102  Permission is hereby granted, free of charge, to any person obtaining
103  a copy of this software and associated documentation files (the
104  "Software"), to deal in the Software without restriction, including
105  without limitation the rights to use, copy, modify, merge, publish,
106  distribute, sublicense, and/or sell copies of the Software, and to
107  permit persons to whom the Software is furnished to do so, subject to
108  the following conditions:
109 
110  The above copyright notice and this permission notice shall be
111  included in all copies or substantial portions of the Software.
112 
113  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
114  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
115  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
116  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
117  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
118  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
119  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Note: See TracBrowser for help on using the repository browser.