-
-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFE: parser option to report ignored and inserted tags #845
Comments
Also, thought |
Thanks for the proposal! This was implemented in #930: Both About a strict mode: I am not sure how much value this would provide. |
@fb55 Hi, I wonder when |
The implicit flag is added whenever a tag should be opened or closed (following the HTML spec), but isn't found in the input. Eg. a |
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 viaonerror
or a separate handler callback, OR as follows:strict mode
,onclosetag
is called for all closing tags, including skipped ones.onclosetag
is 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.
The text was updated successfully, but these errors were encountered: