W3C home > Mailing lists > Public > public-html@w3.org > July 2007

Re: (code, sample output and keyboard/device input <code>, <samp>, <kybd>) part of my review of 3.12 Phrase elements

From: Thomas Broyer <t.broyer@gmail.com>
Date: Fri, 20 Jul 2007 15:58:39 +0200
Message-ID: <a9699fd20707200658r8512ae3r1d185b882323024f@mail.gmail.com>
To: public-html@w3.org

[About syntax highlighting in <code>]

2007/7/20, Lachlan Hunt:
>
> However, it might be worth documenting how authors already solve this
> problem to provide syntax highlighting and it might be possible for the
> microformats community to address the issue.
>
> Some pages use javascript to add the highlighting.  For example:
>
> This uses <pre class="javascript">
> http://dean.edwards.name/weblog/2007/04/packer3/
>
> This uses <pre><code class="javascript">
> http://livepipe.net/projects/event_behavior/
>
> Maybe it would be possible to write a browser extension using similar
> scripts that could perform the syntax highlighting, particularly if the
> microformats community came up with hCode or something.  But, I really
> think more research and documentation of existing use cases and real
> world examples is needed before any good solution can be developed.

google-code-prettify [1] only needs class=prettyprint (on either <pre>
or <code>) and automatically detects the language for you.

You can of course use <pre class=prettyprint><code> or <pre><code
class=prettyprint>

(the latter seems to be better as the former has messed the <code>,
but I ran my tests changing the project's README.html live from within
Firebug and then calling prettyPrint() on Firebug's console).

[1] http://code.google.com/p/google-code-prettify/

-- 
Thomas Broyer
Received on Friday, 20 July 2007 13:59:09 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:16:02 GMT