monkdiscuss
OeufMayo
code
download
<p>As I was answering a SOPW question this morning, I wrote some snippets of code that, if taken alone, would not compile. I also wrote the running piece of code on the node. But because I enclosed the snippets in <code> tags, the 'd/l code' button became useless for one to download only the working script.</p>
<p>I worked around the problem by putting the snippets in <tt> elements, but this element doesn't behave in the same way the <code> does.</p>
<p>So, I was thinking of adding an attribute ('nodownload="1"') to the <code> element, so that whenever this attribute is found, the 'd/l code' functionnality skip this element.</p>
<p>Example:</p>
<code>
<code nodownload="1">
$x = $foo . $x;
</code>
<tt></code></tt>
<p><p>The code above isn't really useful by itself</p></p>
<code>
<code>
#!/usr/bin/perl -w
use strict;
my $foo = 'foo';
my $x = 'bar';
$x = $foo . $x
print $x
</code>
<tt></code></tt>
<p>Of course, on the drawback of such functionnality (except adding a line to the kilometer-long Perlmonks todo list) is that it breaks strict HTML compatibility.</p>
<kbd>-- <br>
my $<a href="/index.pl?node=OeufMayo&lastnode_id=1072">OeufMayo</a> = new PerlMonger::Paris({http => '<a href="http://paris.mongueurs.net">paris.mongueurs.net</a>'});</kbd>