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

Last change on this file since 27132 was 27132, checked in by sjamaan, 9 years ago

Update colorize changelog

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