div & span support
showdown at attacklab.net
Mon Mar 5 15:01:01 EST 2007
Michel Fortin <michel.fortin at michelf.com> wrote:
> > Like when you <div>don't skip lines</div> around HTML blocks.
> I would consider that as a bug. Note that PHP Markdown Extra's HTML
> parser handle this quite well, but this has a cost in complexity and
Yup, I consider that a bug too. I'm saying that if paragraph
wrapping is the main obstacle to parsing Markdown within all HTML, we
can probably fix the rules (and the bugs) so that it behaves well in
the vast majority of cases. I may be wrong about that, which is why I
asked about it on Friday. But so far I haven't heard any reasons it
can't be done.
> > <p>...when you omit close tags.
> I don't think this can be handled correctly in the general case,
> although it certainly could be handled more elegantly for a vast the
> majority of times by considering the paragraph closes at the first
> blank line. I'm not sure it's worth adding a special case for it
Browsers handle it well in the general case with straight HTML: "when
you get to an element that the current element can't contain, consider
the current element closed." You're right: having Markdown's HTML
parser do the same thing at blank lines should work for us. And it's
absolutely worth doing if it gets us the ability to use Markdown
freely within HTML blocks.
> That's not even valid HTML... It works fine when I change the third
> `<div>` for a closing tag however.
Typo tomfoolery. Here's a working example:
This is just one line, so I don't want it wrapped in a paragraph.
I brought all this up because I believe that getting rid of Markdown's
different handling of block elements and inline elements would make
the language a lot more orthogonal and less confusing for new users.
It's much easier to tell users:
"Mix HTML and Markdown freely, and write `markdown='0'` if something breaks"
"You can use HTML within Markdown freely, but you can only use
Markdown within HTML's 'inline elements' by default. You can use it
within `block elements` if you write `markdown='1'`, but if you're
using nested elements you'll need to add it to every ancestor. When
you enable Markdown processing in an HTML block, Markdown may also add
unwanted paragraph elements."
If nobody here thinks it would be an improvement to be able to use
Markdown within any old HTML block and wrap divs without boilerplate
then I guess I should stop lobbying for it. If you're saying it
can't be done, you may be right -- but my gut tells me it can.
More information about the Markdown-Discuss