Correct behaviour of block elements without leading line break before paragraph
waylan at gmail.com
Wed Sep 26 12:31:25 EDT 2012
On Wed, Sep 26, 2012 at 6:25 AM, joseph Dobson <dobson156 at gmail.com> wrote:
> I hope I haven't missed anything which answers this question on the
> syntax page, but what is the correct behaviour of the following
Ah, yes, you have found one of the many known minor inconsistencies of
Markdown. Specifically, one that is not documented. If you are looking
for correct behavior, try your input on the implementation upon which
all (most?) others are based:
It appears that the implementation you are using matches. The specific
inconsistency here is that it is generally expected that a blank line
must be inserted between different blocks (list, paragraph, etc). The
(undocumented) exception is that headers are parsed regardless of
whether they are separated by a blank line or not.
I believe this may have been intentional to allow a header *before* a
paragraph without a blank line - especially the setext style headers.
However, a side effect seems to be that a header following a paragraph
is also allowed (as is a header in the middle of a paragraph). I
suspect this was simply a side-effect of how the parser was
implemented internally. But now it is part of the expected behavior
and possibly hundreds (thousands?) of documents have been authored
with this behavior. On top of that, most cloned implementations have
copied the same behavior. Which all means you should not expect any
changes any time soon.
In fact, you can check the behavior of numerous implementations here:
To avoid inconsistencies like this, I have made it my personal rule
that whenever I am authoring markdown documents that I always insert a
blank line between blocks - regardless of whether the parser actually
requires them. I would encourage others to do the same.
\X/ /-\ `/ |_ /-\ |\|
More information about the Markdown-Discuss