Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

<code> tags and extra blank lines

by dws (Chancellor)
on Jan 08, 2003 at 21:56 UTC ( [id://225364]=monkdiscuss: print w/replies, xml ) Need Help??

A very minor irritation gets more noticeable when it happens over and over and over. Here's one that's been barely bothering me, but frequently.

When adding code to a post, typing

Text here
<code>
#!/usr/bin/perl -w
use strict;
</code>
results in two blank lines between the text and the code block. Removing the extra line requires deleting a line break, writing:
Text here
<code>#!/usr/bin/perl -w
use strict;
</code>
This can get to be a nuisance. And it doesn't read cleanly in the raw text. So, in a separate system I maintain that also supports code tags, I had the formatting engine recognize when the code tags were alone on a line. Then, the formatter would remove the blank line for for me (by deleting the \n after open tag tag). Works like a charm.

I wonder if something like that would help here. Does the extra blank line you get when <code> appears on a line by itself bother anyone besides me?

If there's a concensus that removing the extra blank line automagically would be a Good Thing, I'll take a shot at a patch.

Replies are listed 'Best First'.
Re: <code> tags and extra blank lines
by PodMaster (Abbot) on Jan 08, 2003 at 22:23 UTC
    It used to bug me but not anymore. If the code was linenumbered, and 1: was always that blank line, then it would really bug me and I'd wanna do something about it. I got used to it, and like the formatting effects (i'd hate to go back adding in a <p> or <br> everywhere I relied on that extra newline). But then again, i'm not sure i'd really mind if it changed. I say go for it.


    MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
    ** The Third rule of perl club is a statement of fact: pod is sexy.

Re: <code> tags and extra blank lines
by sauoq (Abbot) on Jan 08, 2003 at 22:59 UTC

    I find it somewhat irritating. I think it is worth patching. Go for it.

    -sauoq
    "My two cents aren't worth a dime.";
    
Re: <code> tags and extra blank lines
by seattlejohn (Deacon) on Jan 09, 2003 at 00:54 UTC
    Yeah, it definitely bugs me, and I never seem to remember to eliminate that linebreak until I notice the preview looks funny...

    Would a patch have to affect previous posts? I don't know enough about how the site actually stores comments to have any idea.

            $perlmonks{seattlejohn} = 'John Clyman';

Re: <code> tags and extra blank lines
by bbfu (Curate) on Jan 09, 2003 at 04:00 UTC

    It's started bothering more, more recently. Ever since I set my preferences to number code lines. I'm all for fixing it.

    bbfu
    Black flowers blossum
    Fearless on my breath

Re: <code> tags and extra blank lines
by dvergin (Monsignor) on Jan 09, 2003 at 01:31 UTC
    Like you say, it's a persistant but not major annoyance.

    Go for it!

Re: <code> tags and extra blank lines
by vek (Prior) on Jan 09, 2003 at 06:05 UTC
    dws, I think having that extra blank line removed is a good idea. Patch away...

    -- vek --
Re: <code> tags and extra blank lines
by dws (Chancellor) on Jan 10, 2003 at 06:31 UTC
    If there's a concensus that removing the extra blank line automagically would be a Good Thing, I'll take a shot at a patch.

    I've submitted a patch. It was a 1-liner, expanded to 2 lines to add a miniscule performance fix.

Re: <code> tags and extra blank lines
by Acolyte (Hermit) on Jan 09, 2003 at 18:34 UTC

    It never bothered me before, but now that it's been brought to my attention it probably will. Patch away! :-)

    Acolyte
    Studying at the feet of the masters
Re: <code> tags and extra blank lines
by dbush (Deacon) on Jan 10, 2003 at 17:56 UTC

    On a related note; I've noticed that when using the "d/l code" link, a number of blank lines are added to the end. For example the following...

    #perl use strict; use warnings; my @dataLines = <DATA>; print 'Number of data lines: ' . scalar @dataLines . "\n"; __DATA__ 1

    ...which was entered into the text box like this...

    <CODE>
    #perl
    use strict;
    use warnings;

    my @dataLines = <DATA>;
    print 'Number of data lines: ' . scalar @dataLines . "\n";

    __DATA__
    1
    </CODE>

    I would have expected the output to be "Number of data lines: 1" but actually prints "Number of data lines: 4".

    Cheers,
    Dom.

    Update: Changed the actual number output to equal 4 not 3.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-25 11:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found