Allow namespace in tag names and attributes

It can be useful to embed tags with namespaces and have them pass through correctly.

Some parsers already support this:

irb(main):002:0> Kramdown::Document.new("<foo:bar>\nbaz\n</foo:bar>").to_html
=> "<foo:bar>\nbaz\n</foo:bar>\n"

Tag names and attribute names should be allowed to contain :.

Would this be a useful addition to the spec?

Proposal: https://github.com/commonmark/commonmark-spec/pull/648

If you search this form for “xml namespace”, you’ll get a few hits and they may be of interest. A long time ago, we simplified the definition of “autolink” to avoid hard-coding a list of schemes. A consequence of this change is that <foo:bar> meets the spec’s requirements for an autolink.

When we were considering the change, I noted that people might want to use namespaces in xml tags. My last comment on one of the threads is “We might want to think about whether we should allow colons in raw HTML tags, to allow 3 and 4.”

2 Likes