Skip to content

Allow parsing tag with namespace? #112

Open

Description

@ioquatix

It looks like this can't parse a tag with a namespace, e.g. <foo:bar ...>

md4c/src/md4c.c

Lines 999 to 1004 in 25096c7

/* Tag name */
if(off >= line_end || !ISALPHA(off))
return FALSE;
off++;
while(off < line_end && (ISALNUM(off) || CH(off) == _T('-')))
off++;

Can we allow it to parse tags with namespaces? i.e. allow : in the tag name.

Activity

  1. mity commented on May 19, 2020

    @mity
    Owner

    Indeed, it cannot.

    1. It's exactly as CommonMark specification requests, I believe. As such, all compliant implementations won't recognize it.

    2. Generally, the raw HTML support in Markdown/Commonmark is simplified.

    3. Also, I'm not expert in this, but it's more XML rather than HTML thing, isn't it? But I admit, allowing XML tags might have a similar merit as HTML tags.

    Given all that together, it would be imho best if you can open an issue in the CommonMark spec repo.

  2. ioquatix commented on May 19, 2020

    @ioquatix
    Author

    Yes, I've made a proposal here: commonmark/commonmark-spec#648

    Regarding 3, we already support namespaced attributes, so one might consider it an oversight that namespaced tags are not also supported.

  3. craigbarnes commented on Jun 26, 2020

    @craigbarnes
    Contributor

    ... it's more XML rather than HTML thing, isn't it?

    Yes. There's no such thing as a "tag with a namespace" in HTML. The "tag name" tokenizer state consumes everything except [\0\t\n\f />] as part of the basic tag name.

  4. ioquatix commented on Jun 26, 2020

    @ioquatix
    Author

    @craigbarnes does that mean a tag name state can parse <foo:bar/> with a tag name of foo:bar?

  5. craigbarnes commented on Jun 26, 2020

    @craigbarnes
    Contributor

    @craigbarnes does that mean a tag name state can parse <foo:bar/> with a tag name of foo:bar?

    Yes, but foo is not a "namespace" (in the XML sense) when parsed as HTML. Namespace prefixes have specific semantics in XML/XHTML, whereas in HTML it just becomes part of the element name.

    All elements in a HTML DOM tree have a namespace, but it's determined by what nodes are higher up in the tree (e.g. <svg>) rather than explicitly in the markup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions