Markdown within block-level elements

Michel Fortin michel.fortin at michelf.ca
Wed Sep 17 19:57:51 EDT 2014


Le 17-sept.-2014 à 17:46, Alan Hogan <contact at alanhogan.com> a écrit :

> 3. Michel Fortin came up with a clever solution to allow this at authors’ discretion way back when, but it is not popular, and most other flavors ignore the markdown=“1” flag altogether. It is usually echoed into rendered HTML by other flavors. It is One More Thing for an author to memorize, so I don’t love the writing experience with it, either. I would like to see Markdown within block-level elements to be the default.
> 
>  <http://ajh.us/bbmk-title-in-header-extra>

I'll just point out that the markdown="1" trick should be credited to John Gruber. It was his plan to incorporate this into Markdown at some point (and if I recall well, one of the 1.0.2 betas had the feature enabled, but it was removed in later betas because it had issues).

I do agree that it is overly verbose. Perhaps we should have an alternative simpler syntax. I though of this the other day (notice the `*`):

	<header*>
	Header!
	------
	Subtitle
	</header>


> 5. Look for Common Mark, a.k.a. “stdmd 0.1”, in Babelmark.
> 
>  <http://ajh.us/bbmk-title-in-header>
> 
>  Note that it gets the output right: It interprets the <header> tags as block-level tags inside of which I wrote more content. The only other packages to do so were Haskell markdown package 0.1, cheapskate 0.1, and pandoc 1.13.

Here is the conflict. CommonMark interprets it "right" according to your intent, but the Markdown spec by John Gruber is very explicit about block-level HTML elements:

> Note that Markdown formatting syntax is not processed within 
> block-level HTML tags. E.g., you can’t use Markdown-style *emphasis* 
> inside an HTML block.
>
> -- <https://daringfireball.net/projects/markdown/syntax#html>
	
Of course, Markdown.pl doesn't treat `<header>` as a block-level HTML element as this element didn't exist at the time. HTML5 brought us a couple of those block-level elements, and some Markdown parsers have been catching up while others ignored this completely.

I think the spec makes it clear that the content of `<header>` should not be parsed with the Markdown syntax. As for whether the spec is right or wrong in that choice, that is another debate entirely.

As a new flavor, CommonMark is free to deviate from the Markdown spec. But for my part I don't intend to implement a change that'd break who knows how many of a ten year legacy of documents with HTML snippets in them.


-- 
Michel Fortin
michel.fortin at michelf.ca
http://michelf.ca



More information about the Markdown-Discuss mailing list