Skip to content
This repository has been archived by the owner on Aug 26, 2023. It is now read-only.

HTML5 Validation? #19

Closed
shaqq opened this issue Jan 23, 2015 · 4 comments
Closed

HTML5 Validation? #19

shaqq opened this issue Jan 23, 2015 · 4 comments

Comments

@shaqq
Copy link

shaqq commented Jan 23, 2015

@rubys

Do you know if this gem allows HTML5 validation of any sort? I seem to get this to work properly:

Nokogiri::HTML5('<html text </html').errors
# => []
@rubys
Copy link
Owner

rubys commented Jan 24, 2015

Not possible until gumbo-parser adds the underlying functionality. This is being tracked with the following issue:

google/gumbo-parser#39

@stevecheckoway
Copy link
Collaborator

Just now seeing this. #46 should do what you want. It uses Gumbo's internal error mechanism. If that patch (or a similar one) is accepted, someone should tell the Gumbo people how the error API is being used here. I imagine that, eventually, they'll move to a public API.

@stevecheckoway
Copy link
Collaborator

@shaqq I believe this is now supported by nokogumbo. You just need to specify how many errors you want to receive.

Nokogiri::HTML5('<html text </html', max_parse_errors: 10).errors
irb(main):007:0> Nokogiri::HTML5('<!DOCTYPE html><html text </html', max_parse_errors: 10).errors.each do |err| puts err.to_s end
1:27: ERROR: @1:27: Tokenizer error with an unimplemented error message.
<!DOCTYPE html><html text </html
                          ^
1:29: ERROR: @1:29: Tokenizer error with an unimplemented error message.
<!DOCTYPE html><html text </html
                            ^
1:33: ERROR: @1:33: Tokenizer error with an unimplemented error message.
<!DOCTYPE html><html text </html
                                ^

The error messages for these particular errors aren't great. I'm going to close this now.

@shaqq
Copy link
Author

shaqq commented Aug 15, 2018

@stevecheckoway cool, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants