Is there a way to treat Softbreaks as Paragraphs?

One of the first comments when not-so-technical people use Markdown is that they expect a Newline to create a newline (without needing 2 spaces). With the stmd.js it’s possible to set renderer.softbreak = '<br/>'; to do exactly that (assuming var renderer = new stmd.HtmlRenderer()), but it’s also sometimes desirable to create an actual new paragraph for it.

renderer.softbreak = '</p><p>'; works, but that closing tag smells since it requires ambient knowledge about the fact that an opening <p> is there.

I don’t think there is a good way to allow the parser to handle this, since that would introduce ambiguity or options into the spec. So it should be in the renderer, but there seems no good extensibility point in it - renderInline doesn’t seem to have auxiliary information about the fact that it is in an open <p> tag.

I guess it’ll be a problem in any case because of potential newlines in Lists or other elements, but I wonder if someone would have an idea if there is a sane extensibility point not?

2 Likes

I agree we need excellent support for the very, very common convention of treating new lines as line breaks in Markdown.

It is easily the number one “switch” sites immediately flip when they use Markdown. Nothing confuses the average user more than hitting enter and not getting a new line like they expect in every other common input area on the web.

1 Like

Treating newlines as line breaks is already supported easily in the JS reference implementation (I haven’t looked at the C one), and the doc mentions this use case already, saying parsers may provide an option to treat softbreaks as hardbreaks.

However, this is not what is being requested here. The issue is talking about treating softbreaks as paragraphs. IMO, this creates all sort of issues. What happens when someone adds a hardbreak in the doc if you decide to treat newlines as paragraphs ? Does it get a hardbreak or a paragraph change in the output ?

1 Like

Indeed—I’d go so far as to say that requiring the two spaces or backslash is not just unintuitive for average users, it’s completely backwards.

It’s a common convention to allow newlines to be escaped with a backslash, but with Markdown we’re using a backslash to unescape, which seems bizarre. From what I’ve seen, it’s the only part of Markdown that people find truly counterintuitive.

(ETA: As stof says, that’s not really the topic of this request; perhaps a new thread is in order.)

Indeed, "Treat Softbreak as <br/>" trivial (stmd.js is really nicely extensible - you have to read the source though), but treat as a new paragraph introduces all sorts of edge-cases (e.g., what about List Items? Blockquotes?) - I don’t believe this is something the Spec or Parser should touch. I think that it would be up to the renderer to report state down to the individual render-functions.

This might be a case where I’m basically creating my own flavor of Markdown (eeeek) simply because a specific (internal) application for a specific circle of users would benefit from it, so I was more looking if there is already a good extensibility point or if I should create a new Html Writer that makes state available to individual functions.

1 Like

“Softbreak as Paragraph” ?!?

Eeeek… Most likely, the heading of this posting is wrong anyway.
@mstum probably meant to say “Is there a way to treat Linebreaks as Linebreaks ?”

But still Eeeek… that would be a horrible thing for every current user who routinely authors documents in Markdown.
This includes Stackoverflow users.
We already  know  that new paragraphs require a blank line.
We already are  used  for single line breaks in Markdown sources not inducing line breaks in resulting documents.
This is one of the most elementary rules in original Markdown.

Also, I’ve recently started to deliberately insert a new line (“softbreak”) in my Markdown sources for each new sentence.
This helps me to easily + immediately spot long sentences when proof-reading my sources.
It helps me to adjust to my self-imposed writing styleguide.
This guide strives for short-enough sentences for my prose.

(Man, do I already hate it that this editor does not support this mode for me.
Look at this ragged right margin resulting from this.
Terrible!
I now also need to markup every single line for the italics…)

1 Like

Stackoverflow & Friends didn’t! (And I think that’s good.)

It’s a preference. The VAST majority of users (and by that I literally mean 100% of them) expect a newline to be a line break. It’s not a suggestion - it’s a requirement to turn off 2-space-requirement and make a simple linebreak be a break.

Markdown has become one of the first go-to-choices regardless of audience, and even more technical people I work with (the folks who know about and want code blocks and other “advanced” features) expect a newline to be a linebreak.

You’re literally the first person I’ve interacted with that finds the behavior desirable. That’s not to say that either side is right or wrong, but to highlight how important that feature is.

Now, my request is unusual: I want a new paragraph instead of a simple break - and for that, I’d need to change the renderer around a lot.

You’re not counting me in when you determine your '100% of users’ then… I feel neglected now :frowning:

Maybe you should interact with more persons then? :wink:

Oh, I forgot at first: I must be the second person, not the first. Because, John MacFarlane, who drafted + wrote most the spec, did put in this (unwanted by you) behaviour for a reason: he must be finding it desirable too.   :smiley: