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...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Multiple code segments with d/l code, nocode idea
by Zaxo (Archbishop) on Nov 23, 2003 at 06:50 UTC | |
|
Re: Multiple <code> segments with d/l code, <nocode> idea
by tcf22 (Priest) on Nov 23, 2003 at 17:57 UTC | |
|
Re: Multiple <code> segments with d/l code, <nocode> idea
by Wassercrats (Initiate) on Nov 24, 2003 at 05:24 UTC | |
by eric256 (Parson) on Nov 24, 2003 at 16:52 UTC |