Main Stories
Slash Boxes

Slash Open Source Project

Slashcode Log In

Log In

[ Create a new account ]

Newlines in Comments

posted by Krow on 11:10 AM December 9th, 2000   Printer-friendly   Email story
Deven writes "I believe the way Slashdot handles newline characters in comment postings is suboptimal. (I'm posting this here because I imagine it probably applies equally to all Slash sites, not just Slashdot itself.)

Slashdot appears to translate each newline into a <br> tag. My suggestion is to instead translate any sequence of newlines into a <p> tag, and leave single newlines alone. It would still allow paragraphs to be typed naturally (with a blank line between them), without creating the formatting problems often caused by cut & paste (forced line breaks within a paragraph) and the natural tendency to surround <blockquote> sections with newlines.

What does everyone else think? Am I the only one who finds the <br> translation troublesome?"

This discussion has been archived. No new comments can be posted.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login
Loading... please wait.
  • Nobody is interested in discussing this topic?
    Deven

    "Simple things should be simple, and complex things should be possible." - Alan Kay

    --
    Deven

    "Simple things should be simple, and complex things should be possible." - Alan Kay

  • well, I haven't really had any problems with it. I cut and paste stuff all the time and there has never been anything strange in the way the articles appear.
    -- It's either on the beat or off the beat, it's that easy.
    --

    --
    It's either on the beat or off the beat, it's that easy.
  • Agreed. If you want better control, use HTML instead of plain text. If you hit preview first, then you can see any problems, and remove extra newlines you don't want. I can see both sides, and I don't think it matters much.
  • by Anonymous Coward

    converting \n+ to <p> is mis-using the <p> tag. it is meant to be an enclosing element with a start and end tag around some text, not "do two linebreaks." so you'd have to do a bit more work to figure out where paragraphs are and surround them with <p></p>.

    this might not seem tremendously important now but using tags for what they're intended will make things much simpler down the road when you want to move to XHTML or XML.


  • The approach you describe (single linebreak ignored, multiple linebreaks --> <P%gt;) is the one I use for YouGov [yougov.com]. It seemed like the right thing to do because it means that text that's nicely formatted in a text editor will be nicely formatted when transormed into HTML.
    Andy Armstrong, Tagish
    --
    Andy Armstrong, Tagish
  • The approach you describe (single linebreak ignored, multiple linebreaks --> <P>) is the one I use for YouGov [yougov.com]. It seemed like the right thing to do because it means that text that's nicely formatted in a text editor will be nicely formatted when transormed into HTML.

    Then you have some real-world experience with this approach. How has it worked out in practice? Have people been happy with it? Do you receive complaints about it, or suggestions to change it?
    Deven

    "Simple things should be simple, and complex things should be possible." - Alan Kay

    --
    Deven

    "Simple things should be simple, and complex things should be possible." - Alan Kay

  • Performing this conversion doesn't create the problem or even make it any worse. The user could have typed the <p> instead of newlines, and you'll still have the problem. Fixing the tags to fit within strict XHTML/XML is going to take some effort, with or without the change I proposed.
    Deven

    "Simple things should be simple, and complex things should be possible." - Alan Kay

    --
    Deven

    "Simple things should be simple, and complex things should be possible." - Alan Kay

  • What I want is for the "Plain Old Text" mode to work well when just naturally typing paragraphs

    In my opinion, it does. In yours, it doesn't. Can't please everyone.

    how can it not be worth doing?

    Your assumption is that it does it the wrong way now. I disagree. It is a different way of doing it, one that has its own merits, and one that is perfectly acceptable in my view. We would have just as many, if not more, people complain if we changed as those that complain with it how it is now.

  • Since this would be a trivial change (e.g. "s/\n+/

    /g" instead of "s/\n/
    /g"), how can it not be worth doing?
    But you should still close the

    tags (idealy speaking of course), which would take more effort, no?

    Joshua


  • Agreed. If you want better control, use HTML instead of plain text. If you hit preview first, then you can see any problems, and remove extra newlines you don't want. I can see both sides, and I don't think it matters much.

    Sure it matters. It affects the usability of the system. What I want is for the "Plain Old Text" mode to work well when just naturally typing paragraphs, without getting screwed up by single newlines within a paragraph. (If I use "HTML Formatted", I have to insert <p> tags manually, which is a nuisance.) Ignoring single newlines and translating sequences of newlines into <p> would make the system more usable and less prone to misformatting. The current approach of translating every newline into <br> makes paragraph breaks work okay, but also makes misformatting too easy.

    Since this would be a trivial change (e.g. "s/\n+/<p>/g" instead of "s/\n/<br>/g"), how can it not be worth doing?

    Deven

    "Simple things should be simple, and complex things should be possible." - Alan Kay

    --
    Deven

    "Simple things should be simple, and complex things should be possible." - Alan Kay

  • What I want is for the "Plain Old Text" mode to work well when just naturally typing paragraphs

    In my opinion, it does. In yours, it doesn't. Can't please everyone.

    You left out the rest of the sentence: "without getting screwed up by single newlines within a paragraph." Yes, if you just type the entire paragraph and hit return twice, it works fine. But, if you have single newlines in the text, either from cut-and-paste or from mistakenly thinking you should hit return yourself near the margin, then yo

    --
    Deven

    "Simple things should be simple, and complex things should be possible." - Alan Kay