[thelist] Syntax Highlighting
Jeff Howden
jeff at jeffhowden.com
Thu Oct 13 22:48:03 CDT 2005
Listees,
I'm working on a personal project that involves *lots* of source code being
displayed online. Standard fixed-width, black text on a white background
just isn't going to cut it here. I've already got things like line
numbering, wrapping of lone lines, etc. taken care of. However, there's one
remaining, complex issue I've yet to find (or build, but yuck) a solution
for. I need to be able to have the source code displayed with syntax
highlighting. Optimally, it should be as close as possible to the default
syntax highlighting in Macromedia's Homesite+.
Here are some basic requirements:
- Must be something I can execute at or near
runtime. In most cases, the source code is of
"live" templates on the server. Obviously,
it doesn't make sense to have the live version
and a syntax highlighted version, creating two
documents that must be updated everytime there's
a change.
- Can be either server-side or client-side.
- Server-side should be in some way possible
using ColdFusion whether that's an external
webservice, HTTP form POST, Java package, or
even something I can execute from the command
line.
- Client-side only has to be IE6+ compatible.
Other browser support is nice, but not
required.
- Must not use <font> tags for markup. I'd much
rather <span> tags are used.
- Must use the class attribute and not the style
attribute for highlighting so syntax highlighting
can be controlled externally via a stylesheet.
- Must support "plug-ins", "brushes", or "language
syntax definitions" for a number of languages,
with a mechanism for building any that aren't
already available. From the start, I'd like for
it support the following:
- XHTML/HTML
- SQL/T-SQL
- CSS
- JavaScript
- VBScript
- ColdFusion
- XML
- Must support syntax highlighting of more than
one language in the same document. For example,
I may load up a document that has XHTML, CSS,
and JavaScript in it. I want the appropriate
elements from each to be correctly colored.
Additionally, it must be smart. For example,
it should use CSS-only highlighting rules
for things it encounters between <style></style>
tags and as "style" attribute values. It
should use JavaScript-only highlighting for
things it encounters between <script></script>
tags and as event handler attribute values,
except when encountering a document.write or
innerHTML string value that contains HTML, in
which case it should use HTML rules.
- Ideally, I want to have fine-grained control
over not only tags and what color they're
given, but also coloring of attributes,
attribute values, reserved words, keywords,
operators, comments, punctuation, etc., each
language specific. I'd also like to be able
to group certain tags together into common
sets. For example, form, fieldset, legend,
label, input, select, optgroup, option,
button, and textarea are all a part of the
"form" set, while table, caption, thead, tbody,
tr, th, td, colgroup, and col are all a part
of the "table" set.
- Would be nice if it detected and converted
email addresses, URLs, UNC paths, etc. into
clickable links.
- Would also be nice if the tags for
highlighting didn't span rows. I know this
will increase the final filesize, but that'll
mean it'll integrate with what I've already
put together with the least amount of headache.
Anybody seen anything like what I'm looking for? I've looked all over the
place, but everything I find seems to have some sort of fatal flaw.
The most promising that I've looked into. I just need to figure out how to
use it.
http://ostermiller.org/syntax/tohtml.html
Others I've looked into that are close, but fail on one important point or
another.
http://www.dreamprojections.com/SyntaxHighlighter
http://dean.edwards.name/my/examples/star-light/
http://simon.incutio.com/js/syntaxHighlight.html
http://www.actiprosoftware.com/Products/DotNet/CodeHighlighter/InlineCode.as
px
http://helene.muze.nl/
Thanks,
[>] Jeff Howden
jeff at jeffhowden.com
http://jeffhowden.com/
More information about the thelist
mailing list