Re: Fwd: Add an @type attribute on code

Cameron McCormack wrote:
> Garrett Smith:
>> What about:
>>
>> <script type="text/monkeyscript" disabled="disabled">
>> // your script text
>> </script>
>> 
>> This would offer the ability to have a disabled script render as just text;
>> 
>> script [type=text/monkeyscript] {

script[type="text/monkeyscript"] {

> I think this would suffer from the major drawback that in UAs that do
> not understand the disabled="" attribute on <script>, the script will be
> executed.

It will only be executed if the UA understands that script type. I don't 
know of any with text/monkeyscript support, though it does become a 
problem if you want to display JavaScript source.

You could make up something like <script type="text/javascript+src"> and 
use a script[type$="+src"] selector, and then the script wouldn't be 
executed. (You can't use type="text/javascript;src=1" because (at least) 
Firefox ignores type parameters other than 'version' when deciding 
whether to execute the script.)

But this doesn't work in (at least) Opera 9.2 (that CSS doesn't make the 
script text visible) or IE6 (the script text is not even in the DOM).


Michael A. Puls II wrote:
> <code class="c++">#include &lt;iostream&gt;
> using namespace std;
> 
> int main() {
>  cout &lt;&lt; "Hello, world!\n";
> }</code>

That should be:

<pre><code class="c++">#include &lt;iostream&gt;
using namespace std;

int main() {
     cout &lt;&lt; "Hello, world!\n";
}</code></pre>

or maybe:

<xmp class="c++">#include <iostream>
using namespace std;

int main() {
   cout << "Hello, world!\n";
}</xmp>

which looks much nicer (and <xmp> is supported by (at least) 
IE/Firefox/Opera/Safari/Lynx/w3m)

-- 
Philip Taylor
pjt47@cam.ac.uk

Received on Saturday, 8 December 2007 14:13:32 UTC