You said that the statements:
A conforming parser may render a soft line break in HTML either as a line break or as a space.
A renderer may also provide an option to render soft line breaks as hard line breaks.
contradict each other. They don’t because the browser removes line breaks/multiple spaces down to one space in <p>
tags anyway. Therefore, it doesn’t create inconsistencies.
The statement “A softbreak may be rendered in HTML either as a newline or as a space. The result will be the same in browsers” was referring to this:
aaa
bbb
being converted to:
<p>aaa
bbb</p>
or:
<p>aaa bbb</p>
Which is not a problem because the browser renders both in the same way:
aaa bbb
The spec is quite clear on this. A hard line break is quote:
A line break (not in a code span or HTML tag) that is preceded by two or more spaces is parsed as a linebreak
Soft line break (emphasis mine):
A regular line break (not in a code span or HTML tag) that is not preceded by two or more spaces is parsed as a softbreak.
In addition to this, “two or more spaces” can be swapped with “a backslash”; see example 427.
Your definition of hard line breaks and soft line breaks:
- Hard line breaks are when the user hits the enter key (and gets a carriage return/linefeed/or both, depending on system).
- Soft line breaks are when the displayer/viewer (the browser) decides to wrap lines that are too long.
is completely different. Stmd is always referring to when you hit the enter key, your “hard line break”, as a ‘line break’.
- Your soft line breaks are not referred to in the spec, since as you say, there is “no need to mention it in the spec”.
- Stmd then differentiates between your ‘hard line breaks’, and splits them into what it calls a “hard line break”, or a “soft line break”, depending on whether or not they are preceded by a back slash or two or more spaces, provided they are not within a code span or html tag.
I know that this is exactly what you are arguing for though, because when all line breaks (whenever you press enter not in a code span/html tag) are converted to a <br>
tag, there is no need to split up the definition of ‘line break’ into whether or not it is preceded by a back slash or two or more spaces, i.e. what stmd currently refers to as “hard” or “soft” line breaks.
I just wanted to clear up the differences between your definition of soft and hard line breaks and what stmd currently uses.
On that note though, I still disagree with your proposal. Turning all line breaks into <br>
tags certainly must not happen as it would disastrous to backwards compatibility to say the least. You still haven’t provided a solution for those that hardwrap their text, other than simply saying it’s wrong.
So that is what I meant. Under your proposal, the only way to have paragraphs without <br>
tags forced in it, is to have long lines obviously. The desire to not have <br>
tags in the html output is because you might not exactly want to wrap at those points when the paragraph is displayed in the browser (let the browser do the wrapping for you).
(But of course you may still want to have hard line breaks in the original text for better readability in the original text itself. For example, in emails, where plain text emails is much more commonly used than html emails.)
This is how it has always been for a long time and changing that would certainly be against the spirit of markdown since markdown was all about what people already did and creating a syntax from that. I’m all for ‘moving forward’, but this would be the wrong decision and break too many things in my opinion.
No, example 435/436 is about how stmd handles these cases. These examples help clarify it.