Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

A 'nodownload' attribute for the code element?

by OeufMayo (Curate)
on Aug 15, 2001 at 14:17 UTC ( #105003=monkdiscuss: print w/ replies, xml ) Need Help??

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.

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.

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.

Example:

<code nodownload="1"> $x = $foo . $x;
</code>

<p>The code above isn't really useful by itself</p>

<code> #!/usr/bin/perl -w use strict; my $foo = 'foo'; my $x = 'bar'; $x = $foo . $x print $x
</code>

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.

<kbd>--
my $OeufMayo = new PerlMonger::Paris({http => 'paris.mongueurs.net'});</kbd>

Comment on A 'nodownload' attribute for the code element?
Select or Download Code
Re: A 'nodownload' attribute for the code element?
by jepri (Parson) on Aug 15, 2001 at 14:33 UTC
    Even a macro that expands NYT to "Warning! Untested code" would be good"

    And your idea won't break compatibility with HTML because the HTML standard is very clear that any unknown tags or attributes are to be ignored.

    ____________________
    Jeremy
    I didn't believe in evil until I dated it.

Re: A 'nodownload' attribute for the code element?
by blakem (Monsignor) on Aug 15, 2001 at 14:34 UTC
    I like this idea, but it seems a bit long. To override the default behavior, perhaps 'download=0' instead of 'nodownload=1'. Or, maybe a new tag like <snippet> would make more sense.

    -Blake

      Why not even shorten it to <code dl="[0|1]">

      elbieelbieelbie

(tye)Re: A 'nodownload' attribute for the code element?
by tye (Cardinal) on Aug 16, 2001 at 00:24 UTC

    You could always just slip q{ into the conversation before the

    # Danger! Untested code here! unlink glob("*");
    and then slip a "miserable face" (};) after it so that
    # Wow! Cool code! #line 3 "work, while snorting" die;
    is the code that gets run!

            - tye (but my friends call me "Tye")

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: monkdiscuss [id://105003]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2014-11-24 01:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (135 votes), past polls