- From: Taylor Hunt <taylorcharleshunt@gmail.com>
- Date: Sat, 9 May 2015 00:27:02 -0400
- To: whatwg@whatwg.org
Hello, I was wondering about the best way of indicating a <code> element's contained computer language for syntax highlighting. The specifications are quite clear that using @lang for that is abuse, so many existing implementations use a data-lang attribute, class name, or something similar. I was curious if repurposing the "type" attribute onto <code> elements for this purpose would be a good idea. The <script> and <style> elements already use it to indicate what language they contain, so there would seem to be precedent. (An argument against this would be <input> already overloading type's meaning, but that ship may have sailed.) Including non-standard languages within these tags with a differentiating value for type is widely-practiced, such as for HTML templating, or more exotic implementations like in-browser interpreters or thegrid.io's use of <style type="text/gss">. Using code[type] would have the advantage of an existing vocabulary for unambiguously indicating a code language, through MIME types. It also works today, and should have no problems in older browsers. The most obvious benefit would be syntax highlighting, but there could be other use-cases: more intelligent enunciation by speech synthesizers, for example. Thanks for your time, Taylor Hunt
Received on Saturday, 9 May 2015 04:27:27 UTC