Update: *cough cough*, this node shows how often I use the d/l code functionality. There already is a separation done, so I think I withdraw that part of the question (namely 75% of this node's content). I'll stick with my <nocode> idea though (scroll to last paragraph to read up on that).

/(?:some|many|most|all)/ of us have written node(s) where we provide a snippet of code and then include short cut-outs of code within regular text (ie: your not really providing code, you're just highlighting a certain line). Or perhaps you're someone who has at least once used more than one set of <code></code> tags. So you end up with something like the following:

<p>Here's some code:</p>
<p>
<code>
#!/usr/bin/perl -w
use strict;

my $foo;
</code>
</p>
<p>
The <code>my $foo</code> line declares a variable.
</p>

Okay, dumbed down example, but I know a lot of people do this (/me admits to being one of these people). So now, if someone uses the d/l code link provided to download the code contained within the node, they'll get all text within that node contained between <code> tags. So it all gets mixed together and you have yourself a big mess (something like this):

#!/usr/bin/perl -w
use strict;

my $foo;my $foo

My ingenious idea? The code handling the 'd/l code' node should separate the text between each pair of <code></code> tags. They should be numbered or pointed out via a comment line, indicating that the multiple code snippets were authored separately within the node. Clicking the 'd/l code' link on my above example would yield a downloaded file something like the following. Note that this would also be great for nodes that actually provide multiple larger snippets of code.

# code segment #1
#!/usr/bin/perl -w
use strict;

my $foo;


# code segment #2
my $foo

As a second idea (not too far off the above topic to be worthy of its own root pmdiscuss node), how about a set of <nocode></nocode> tags that format the exact same way as <code></code> tags but get skipped by the d/l code node. That way, everyone who currently uses a combination of <pre></pre> and <font></font> tags to emulate code-format could instead just use a simple new tag (that would of course follow the options from user settings (such as number of columns before code wrapping)). The only problem I could see with this would be users being confused by what results they'd get from a 'd/l code' link (ie: They see a snippet of code, click 'd/l code' to retrieve it, only to find that it doesn't get downloaded because the author used <nocode> instead of <code>. This problem would of course be circumvented if we just forget the <nocode> idea and implement my first idea. But it still sounds good enough for me to suggest. Especially if authors reserve the <nocode> sets specifically for inline "pointer" code (such as the "The <code>my $foo</code> line declares a variable." example from above).

Thoughts on this please...


In reply to Multiple <code> segments with d/l code, <nocode> idea by Coruscate

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.