You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use CommonMark as our document parser at the Seattle Times on some special projects, and it has problems recognizing our custom elements when we try to insert them into the document as HTML. For example, this is not recognized:
But this is ugly, and it goes against the point of our custom elements, which is to be more usable for non-technical producers. Can we get the HTML parser to recognize these valid elements as HTML?
Currently the spec hard-codes a list of HTML block elements (and this isn't one, obviously). But, in response to some other issues, I'm thinking of changing the spec to hard-code the elements that can NOT start HTML blocks, instead. That would solve your problem.
@puzrin, my idea had been that any HTML tag that begins a block, except for a select few designated ones that are used for span-level content, would start an HTML block. But that's a bit crude, as in principle one might define a span-level custom tag and decide to start a paragraph with it.
Of course, one could go to a system where custom tags can be registered as block or inline tags through options to the program or library. I'd rather avoid that, though -- and even with the tags that HTML provides, we face many cases of ambiguity. For example, is <del> at the beginning of a line meant to enclose the entire paragraph (a block) or should it be interpreted as an inline tag inside the paragraph?
I'm very much tempted by the following rule, which is easy to remember and use: to start an HTML block, put a single HTML tag on a line by itself. (The block then continues until...etc.) Thus,
<del>
Content inside block-level tags.
</del><del>A paragraph with inline-level tags.</del>
With this rule, we wouldn't need to build in any distinction between block-level and span-level HTML tags.
The main worry here would be about backwards compatibility, since existing Markdown processors don't have this restriction.
An alternative system would use a mix of heuristics, following the current CommonMark spec for known HTML elements, but using the rule above for unknown ones. Aesthetically, this is ugly, but it might achieve more backwards compatibility.
Activity
jgm commentedon Dec 8, 2014
Currently the spec hard-codes a list of HTML block elements (and this isn't one, obviously). But, in response to some other issues, I'm thinking of changing the spec to hard-code the elements that can NOT start HTML blocks, instead. That would solve your problem.
thomaswilburn commentedon Dec 8, 2014
That sounds like a good solution, thanks.
colinodell commentedon Dec 8, 2014
+1 I like the idea of blacklisting elements instead
jgm commentedon Dec 13, 2014
See also http://w3c.github.io/webcomponents/spec/custom/
jgm commentedon Dec 13, 2014
So, here's the plan. Both items need to be implemented in the spec, in the C parser, and in the JS parser.
puzrin commentedon Dec 13, 2014
How are you going to define, if certain custom tag can or can not start html blocks?
jgm commentedon Dec 14, 2014
@puzrin, my idea had been that any HTML tag that begins a block, except for a select few designated ones that are used for span-level content, would start an HTML block. But that's a bit crude, as in principle one might define a span-level custom tag and decide to start a paragraph with it.
Of course, one could go to a system where custom tags can be registered as block or inline tags through options to the program or library. I'd rather avoid that, though -- and even with the tags that HTML provides, we face many cases of ambiguity. For example, is
<del>at the beginning of a line meant to enclose the entire paragraph (a block) or should it be interpreted as an inline tag inside the paragraph?I'm very much tempted by the following rule, which is easy to remember and use: to start an HTML block, put a single HTML tag on a line by itself. (The block then continues until...etc.) Thus,
With this rule, we wouldn't need to build in any distinction between block-level and span-level HTML tags.
The main worry here would be about backwards compatibility, since existing Markdown processors don't have this restriction.
An alternative system would use a mix of heuristics, following the current CommonMark spec for known HTML elements, but using the rule above for unknown ones. Aesthetically, this is ugly, but it might achieve more backwards compatibility.
thomaswilburn commentedon Dec 14, 2014
I could live with that for custom elements, although I also think it'd be okay to just treat custom elements as block level by default, personally.
jgm commentedon Dec 29, 2014
Discussion here: http://talk.commonmark.org/t/raw-html-blocks-proposals-comments-wanted/983
Allow non-initial hyphens in html tag names.
Allow non-initial hyphens in html tag names.
jgm commentedon Jul 11, 2015
@thomaswilburn - Note the following.
will be treated as a raw HTML block, and reproduced verbatim.
will be treated as a paragraph with inline HTML tags, and reproduced with
<p>...</p>surrounding it.See the new spec for HTML blocks (still in master, not published) for further details on how this works.
thomaswilburn commentedon Jul 11, 2015
Awesome, thanks John.
Allow non-initial hyphens in html tag names.
Refuse a message the HTML parser repairs for the repair alone, before…