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

suggestion : change to code tag

by boo_radley (Parson)
on May 19, 2001 at 06:48 UTC ( [id://81677]=monkdiscuss: print w/replies, xml ) Need Help??

frequently, many people will post something similar to the following in SoPW :

I am having problems with my script, foo.pl.
I try to run it, but I get "error : broken widget, line 54"
What does this mean? I'm sure I've initialized $widget properly. Please help!

my $widget; ... etc.

but I don't recollect ever seeing "the lines posted start at 51, stop at 60, then resume at 90 on the next snippet", or somesuch. This occasionally makes it difficult to troubleshoot what's going on.
THEREFORE
I would like to suggest adding an ATTRIBUTE to the honorable <code> tag, startline. When the startline attribute is present,e.g.,  <code startline=51>..., the output would be similar to the code catacombs :

51 : my $widget; 52 : ... 53 : ... 54 : my $widget->break(horribly); 55 : ...
and so on.

Replies are listed 'Best First'.
Re: suggestion : change to code tag
by Masem (Monsignor) on May 19, 2001 at 07:23 UTC
    I've previously made mention of this idea in Suggestion: Optional Line Numbering Tag for CODE, though as we've already got problems getting newer users to use CDOE to start with, having an extra attribute may be tougher.

    I think a better solution is to introduce another new tag, NCODE, which standard for "numbered code". Same effect as the above, of course, and probably easier to remember.


    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
(dws)Re: suggestion : change to code tag
by dws (Chancellor) on May 20, 2001 at 02:36 UTC
    Allowing a starting line in a code tag is supposed to make it easy to intermix descriptions with code, while keeping line numbers continuous across code blocks. However, this makes it hard for authors to revise their submissions (either during an edit/preview cycle, or later). If I decide to add a comment to a code example, I would need to manually adjust some number of startline attributes in subsequent code tags. Being an error-prone human, I'm liable to miss one, or get the counts wrong. Instead, I'd rather declare a code block to be a continuation of a previous code block, and leave the line counting to the underlying formatting engine.
    <code>
    my $widget;
    ...
    </code>

    Explanation of the first block.

    <code continue>
    sub foo {
        ...
    }
    </code>

    Explanation of the second block.
    knobunc describes a more elaborate version of this here.

Re: suggestion : change to code tag (discussion)
by deprecated (Priest) on May 21, 2001 at 01:56 UTC
    This is a good idea. However, we have enough of a problem getting newbies to use <code> to begin with. I think our more experienced users who would be able to make use of such an attribute already make it very clear when theyre posting a question to SoPW.

    just my take on it,
    bro' shondepro

    --
    Laziness, Impatience, Hubris, and Generosity.

      i think adding optional line numbers would not make it any harder to get newbies to use them, and if it would simplify life for the people who felt like using it, i'm in favor. at least we aren't suggesting automatically wrapping any writeup by someone of less than monk status that also contains a $ in <CODE> tags if it contains none.

      though it might work...
Re: suggestion : change to code tag
by tadman (Prior) on May 23, 2001 at 20:10 UTC
    Further to the <CODE> tag discussions, my $2e-2 is that there be an INDENT parameter, which would shuffle the code in, only during HTML display. A default of 5 characters would be assumed, unless a specific number was specified, such as INDENT=8. This gives you code like:      my $donut = 'round'; Instead of: my $donut = 'round'; The downloaded code would stay unindented. I find that indenting often improves readability for short blocks, and most books (i.e. Programming Perl) use this same technique.

    Of course, vroom probably has 9e6 other things to do first.
      You can get this effect by putting a BLOCKQUOTE tag around your CODE tag. The code will indented in the HTML display, but not in the d/l code display.

      I'm assuming that code is just a style declaration?? If not, why not?

      div.code
      {
           text-indent: 10px;
           font: fixed;
           bgcolor: Floral White;
      }
      

      Or Even....

      div.code
      {
           normal style declaration
      }
      div.indent
      {
           text-indent: 10px;
      }
      

      Just tossing it out there...

      Hammy

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2024-04-23 14:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found