-
-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom elements not supported #239
Comments
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. |
That sounds like a good solution, thanks. |
+1 I like the idea of blacklisting elements instead |
So, here's the plan. Both items need to be implemented in the spec, in the C parser, and in the JS parser.
|
How are you going to define, if certain custom tag can or can not start html blocks? |
@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 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. |
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. |
This allows for custom tags, see commonmark/commonmark-spec#239.
This allows for custom tags, which in HTML5 MUST contain a hyphen. See commonmark/commonmark-spec#239.
@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 See the new spec for HTML blocks (still in master, not published) for further details on how this works. |
Awesome, thanks John. |
This allows for custom tags, see commonmark/commonmark-spec#239.
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:
A workaround is that we can wrap it in a known HTML element, such as a div, and that will be 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?
The text was updated successfully, but these errors were encountered: