Skip to content
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

Possible to add option to validate HTML fragments? #150

Open
samdutton opened this issue Jul 12, 2019 · 8 comments
Open

Possible to add option to validate HTML fragments? #150

samdutton opened this issue Jul 12, 2019 · 8 comments
Assignees

Comments

@samdutton
Copy link

Not sure if this is possible, but I'd love to be able to use this to validate HTML fragments as well as complete documents.

Great module, by the way — thanks!

@zrrrzzt zrrrzzt self-assigned this Jul 12, 2019
@zrrrzzt
Copy link
Owner

zrrrzzt commented Jul 13, 2019

I can look into it :-)

Can you give me some example code to make it clear what you want to validate?

@p1ho
Copy link
Collaborator

p1ho commented Jul 13, 2019

My 2 cents:

  • If you want to verify complete documents that are offline, you can set isLocal to true, and use the localhost url to verify.
  • If you want to verify fragments, I'm not sure if this is within the scope of this package, but you'd basically stuff your fragments inside a valid html template inside the body tag, and try to verify that I think? a few things may be off though (like line number) that you'd need to correct.

@zrrrzzt
Copy link
Owner

zrrrzzt commented Jul 13, 2019

My idea is to wrap the fragments in <html><body></body></html> and use the validator as usual.
You would probably need to activate this sort of behaviour with a special flag.

This would work if fragments = parts of html.

@p1ho
Copy link
Collaborator

p1ho commented Jul 13, 2019

I think the base template has to be a bit more complicated than that.
I tested just now with w3c validator. and I think this is the bare minimum you need.

<!doctype html><html lang=""><head><title>fragment</title></head><body>
  <!-- insert fragment -->
</body></html>

@zrrrzzt
Copy link
Owner

zrrrzzt commented Jul 13, 2019

Yeah, that's the minimum for a valid document.
I don't think it would require much effort to add this functionality either.
I'll look at it tomorrow.

@samdutton
Copy link
Author

samdutton commented Jul 14, 2019 via email

@zrrrzzt
Copy link
Owner

zrrrzzt commented Jul 14, 2019

Just released version 4.1.0

Now you can add fragments as data and set isFragment to true.

Hope this works out for you use case @samdutton

@samdutton
Copy link
Author

samdutton commented Jul 14, 2019 via email

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

No branches or pull requests

3 participants