- From: Laurens Holst <lholst@students.cs.uu.nl>
- Date: Wed, 13 Jul 2005 02:57:52 +0200
- To: Simon Siemens <Simon.Siemens@web.de>
- Cc: XHTML-Liste <www-html@w3.org>
Simon Siemens wrote: > Yes, we have additional semantics by "code" and "blockcode". But what > is the usage? It's the same as adding a tag for exclamation sentences > like: Well, as a use case, look at the following example [1]: <blockcode class="program"> <l>program p(input, output);</l> <l>begin</l> <l> writeln("Hello world");</l> <l>end.</l> </blockcode> With the following CSS (slightly modified): blockcode { counter-reset: linenumber } blockcode l:before { position: relative; left: -1em; counter-increment: linenumber; content: counter(linenumber); } This would create automatic line numbering, which makes sense for code, but not for other preformatted content such as a poem where whitespace matters [2]. Also, the blockcode example [3] shows how class is used to designate the language of the code. Given the objections that I mentioned with regard to naming conventions (assembly or asm?), misuse (js for c++), and the limited usefulness of such information, I think that this is probably the best solution. Downside: outside the context of the webpage and its styling, e.g. in search engines, it will not be possible to reliably detect the language. Although a clever search engine will immediately recognise blockcode with class="Perl" as Perl code, of course. I’d say based on a mapping of common classnames for languages (e.g. "asm" -> "assembly", "z80" -> "assembly", "py" -> "python") and perhaps some partial matching and probability calculations, the language contained in a block of code can be determined relatively reliable. Especially when combined with analysis of the content of the blockcode. It is not simple, but a ‘code search engine’ would be a specialised piece of software anyway. And if standardising of some class values is necessary, a microformat could take care of that... (if I correctly grasped the concept of microformats :)) ~Grauw [1] http://www.w3.org/TR/xhtml2/mod-text.html#sec_9.7. [2] http://www.w3.org/TR/xhtml2/mod-structural.html#sec_8.7. [3] http://www.w3.org/TR/xhtml2/mod-structural.html#sec_8.2. -- Ushiko-san! Kimi wa doushite, Ushiko-san!! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Laurens Holst, student, university of Utrecht, the Netherlands. Website: www.grauw.nl. Backbase employee; www.backbase.com.
Received on Wednesday, 13 July 2005 00:57:54 UTC