Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Creating node should automatically add "<br>"

by zejames (Hermit)
on Nov 23, 2004 at 09:09 UTC ( #409844=monkdiscuss: print w/replies, xml ) Need Help??

Dear Fellow monks,

Don't know if this has been discussed numerous times before, but I'd like to make a suggestion about node creation.

It is a feature that, when creating a node, one have to add html tags to format his text. And that is fine. I'm really happy to write my contributions in HTML : that is quite easy for most of us (don't have to learn special tags like in phpBB) and for perlmonks perl code (don't have to substitute that special tags with HTML tags).

However, for me, there is a simple feature that is really missing : adding a special <br> tag at each end of line.

It is not that it is a big pain to add it. I often forget it, but preview remind me of that. I'm just tired of reading nodes in which not <br> tag have been added at all. That really makes them less readable, which is a pity.

So don't you think something should be done for that ?

Update : I realize I've not be clear : what I propose is of course not to add a <br /> at the end of each line (in the textarea), but a the end of each paragraph, that is adding it whenever the poster press "Enter". Otherwise the formating would depend on the browser and the screen resolution, that is very bad.


PS : yes, writing good xhtml is good(TM) so let's use <br /> ;)
  • Comment on Creating node should automatically add "<br>"

Replies are listed 'Best First'.
Re: Creating node should automatically add "<br>" - NO
by apotheon (Deacon) on Nov 23, 2004 at 09:17 UTC

    I disagree. It always bothers me when I see a site that allows HTML/XHTML code in posts but implements them in some half-accurate manner by not allowing some tags, allowing others, and performing the functions of still others without being told. Also, using linebreak tags is inferior to using paragraph tags for purposes of separating paragraphs in HTML/XHTML, in my opinion, but I don't want to enforce that opinion for others. So there.

    Besides, more importantly, I like the fact that I can use whitespace within the source text the way I want to without it affecting code rendering overmuch. I can put six newlines between paragraphs, but because I'm using paragraph tags it only double-spaces. This is, occasionally, of use.

    At most, make it an option for auto-formatting. I prefer leaving formatting entirely up to the user, though.

    - apotheon
    CopyWrite Chad Perrin

    2004-11-27 Edited by Arunbear: Changed title from 'NO.', as per Monastery guidelines

    2004-12-01 Edited by apotheon: properly chastened, resolves to do better next time

      Perlmonks being a community, let's make people choose, as you said : I think it would be very nice if it were a option, a box to check, where both xhtml coder (like you and me) could do whatever they want and not-xhtml-aware posters could write clean posts to read.


        I have to disagree with this dual posting scheme, because it's not straightforward for the user: after posting the node, the user can usually edit it, so how does he edit his node now?? suddenly his node contains HTML tags which weren't there...

        He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.
        Chady |
        Are you a Linux user in Lebanon? join the Lebanese Linux User Group.
Re: Creating node should automatically add "<br>"
by Mutant (Priest) on Nov 23, 2004 at 10:43 UTC
    I think there should be an option for each post to disable HTML. If you check this box, then HTML is added for newlines. This might help newbies, and if you're writing a simple post (like this one), but want to split stuff into a paragraph or two, you don't have to worry about HTML.
Re: Creating node should automatically add "<br>"
by hostyle (Scribe) on Nov 23, 2004 at 15:44 UTC

    While I disagree with the original poster, I've pondered the debate, and if a middle ground needs to be found, something involving Brad Choate's Textile would be very nice.

    This accepts HTML, or if none is specified it adds BR, P, LI and other tags acording to a very simple ruleset. Single newlines become linebreaks. Double newlines denote paragraph. Asterisks denote lists, etc. It would most likely add some overhead to PM however, as its best store the raw text in the database, then apply Textile to it when being rendered as a node, rather than presenting HTML in a TEXTAREA to a user who hasn't entered any.

Re: Creating node should automatically add "<br>"
by CountZero (Bishop) on Nov 24, 2004 at 06:59 UTC
    Otherwise the formating would depend on the browser and the screen resolution, that is very bad.
    I always considered it to be a Good Thing (tm) that each browser adapts the HTML code to its own screen resolution. Isn't this one of the big features of HTML-formating?


    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

      You're absolutely correct. One of the most important features of HTML is that (when used properly) it degrades gracefully when circumstances on the viewing end aren't what the coder expected. That means it should look good in, and maximize appearance for, as many different environments as possible.

      - apotheon
      CopyWrite Chad Perrin

Re: Creating node should automatically add "<br>"
by DrWhy (Chaplain) on Nov 26, 2004 at 16:46 UTC
    Although I would tend to agree that coddling PM newbies too much encourages delayed development -- kind of like what's happening with the delayed emotional and ethical maturation of the rich, coddled, overprotected recent generations in North America and Western Europe (probably Japan too, though perhaps to a lesser degree) -- that doesn't mean that there isn't a reasonable possiblity here for making our lives simpler without taking away power and flexibility when that is desired. Although, I haven't been bothered too much by poorly formated node, I personally find it annoying to have to be throwing <p>'s in all over the place just to get separate paragraphs when the text I'm writing requires no special formatting.

    I would suggest the following. A checkbox is added next to the textarea for creating new nodes. If checked the text is assumed to be 'plaintext' with no HTML in it. It gets filtered according to a very simple set of rules:

    1. Anything that looks like HTML gets escaped (>, <, &, etc.)
    2. All newlines are converted to <br />
    The text thus filtered would be what gets stored in PM. This plaintext option would not be available for updating nodes, only for node creation, since in most cases some HTML would have already been added to the plaintext node by the system.


    • Simple posts can be composed more simply.
    • Minimal extra overhead on PM, only an extra if for each new node posted, plus a one time filtering operation for 'plaintext' nodes. Well, actually the /if( and filtering)?/ would have to happen at least twice for each new node, because you would want to filter the 'preview' version as well.
    • Experienced users need do nothing different to continue to have their same old user experience.
    • In order to be 'lazy', you have to click a check box, a slight barrier to grauitous laziness. The truly lazy and inconsiderate will still end up posting poorly formatted stuff.
    • Very limited rules for plaintext processing gives, I think, maximum benefit for posters who know they are just writing simple block paragraph text, while keeping the required code changes on the backend comparatively simple and small -- especially important is that this doesn't change the way nodes are stored or displayed to readers.
    • Although I envision this as a labor saving device for users with more experience rather than less, an intelligent newbie should be able to take advantage of the feature too in short order, if they don't feel ready to do HTML.
    • If the checkbox is properly labelled, it would be a clue to true newbies that the text they are putting in will be treated like HTML by default.
    • Some purists may be annoyed. To them I say, systems are designed for people, not people for systems. (I was going to say that the luddites would also be annoyed, but since this doesn't actually require them to change their behavior in any way, I would think they wouldn't be bothered too much.)
    • This will of course require more coding work on the PM scripts than not doing anything would.

    "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

Re: Creating node should automatically add "<br>"
by DaWolf (Curate) on Nov 26, 2004 at 06:23 UTC
    I personally miss this too. I've seen a lot of posts that are horrible to read because they are just a huge block of text. Simplifying the OP's suggestion, why not just replace \n with <BR> or <BR />?

    I really don't see why this shouldn't be done...

    Best regards,

      For examples of why not, I recommend you read the rest of the discussion. If you have, I recommend you actually address those arguments so that we know why you think them inferior to your own reasoning.

      Personally, I might find it somewhat annoying when someone doesn't format his or her text worth a damn, but that sort of inattentive, lazy disregard for readability is a pretty clear indicator of the sort of personality of the person behind the text. It provides an easy, first-glance means of deciding what nodes to skip over when I'm feeling impatient or otherwise unwilling to muddle through someone's half-baked natterings. Like well-formed code, well-formed text takes care. If someone can't be bothered to try, I'm not always going to have the motivation to bother trying to read what he or she has to say. I'm fine with that.

      I don't want my own options for how I format my nodes to be limited by the willful ignorance of others. Let's not dumb down PerlMonks to cater to the least common denominator.

      How's that for a reason not to have linebreak tags automatically added by the PM scripts? If that reason doesn't work for you, there are several more reasons in discussion above your comment.

      - apotheon
      CopyWrite Chad Perrin

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2020-10-26 07:56 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (250 votes). Check out past polls.