Thanks to visit codestin.com
Credit goes to github.com

Skip to content

HTML writer: generates invalid data- attributes for empty keys #7546

@gwern

Description

@gwern

According to the HTML/XML standard, the keys in data- attributes must be a valid Name, and a Name must consist of at least one character from the NameStartChar class. Thus, the keys must not be empty strings.

Pandoc, however, will generate nonsensical data attributes which trigger validation errors, confuse browser parsers, and can't be queried or used anyway:

 $ echo 'Span ("", [], [("","")]) []' | pandoc -f native -w html
<span data-=""></span>

A data-="" is invalid. Pandoc should not generate invalid HTML. I suggest it should either crash on being given invalid Attr data, or omit invalid key-value pairs with a warning.

(I admit this is a silly thing to write, but I did do it today while being a bit mentally confused about Attr vs Target and not thinking about "so what sort of attribute is a ("","") anyway?" and then being rather confused at the sudden outbreak of thousands of validation errors. While perhaps few people would manually write out such a nonsense Attr, it is the sort of thing that could be programmatically generated by other bugs upstream, and Pandoc blocking it is a good thing.)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions