Skip to content
This repository was archived by the owner on Oct 4, 2022. It is now read-only.
This repository was archived by the owner on Oct 4, 2022. It is now read-only.

Generating tree structures for HTML with a comment inside a heading or paragraph fails. #2178

@hansjovis

Description

@hansjovis

Generating the tree structure fails for HTML that has a comment within a header or paragraph:

<h1>Hello World!<!-- How are you? --></h1>

The comment gets added to the header as a formatting element, as it should be, but something goes wrong when converting the comment from an Ignored node to a FormattingElement.

It currently errors on the calculation of the start- and end position of the formatting elements.
Specifically on this line, where it fails to get the start tag.

const startTag = element.location.startTag;

More importantly, parse5 recognizes How are you? in the example below as a comment:

<h1>Hello World!</ How are you?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions