-
-
Notifications
You must be signed in to change notification settings - Fork 396
Description
I understand why htmlparser2 gracefully handles malformed HTML, automatically closing unclosed tags and skipping extraneous close tags: because that is how browsers handle it and it is even part of the HTML spec.
But there are use cases where one needs to know that these things are happening. For example I am using the parser as a tool that does some validation and reformatting. I want to know that a tag wasn't closed, or that a close was inserted because it was missing.
Would you be open to an option wherein those events are reported?
For example, there could be a strict mode, which would report these events via onerror or a separate handler callback, OR as follows:
- in
strict mode,onclosetagis called for all closing tags, including skipped ones. - when
onclosetagis called, it includes an additional arg indicating if the tag was skipped or inserted.
This would be backward compatible, and would not affect performance when disabled.