-
Notifications
You must be signed in to change notification settings - Fork 4
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
DOCTYPE lost when the template is a complete document #10
Comments
Ah, |
Well, then at least it's consistent in the browser vs. in node :) |
Would be really nice to get this fixed for when a complete document is rendered on the server. I added a failing test here: https://github.com/papandreou/htmlizer/tree/doctype |
jQuery strips the doctype, html, head and body tags. |
Why would you need one written from scratch? There's plenty of good, existing ones such as https://github.com/fb55/htmlparser2/ and https://github.com/inikulin/parse5. |
Those run only on node. The same parser should support browsers as well. node-htmlparser is an alternative, but it has the same issue. |
Oh... Maybe they work with browserify? |
Hmm...I took a step back. Detecting doctype is mostly as server-side use case. So I'll try to solve this only for nodejs using jsdom instead of jquery.parseHTML. The solution I had in mind is to use |
I'm pretty sure jsdom saves the doctype as |
Ah, but jsdom always creates html, head and body tag, even for HTML fragments (it makes sense because the return type of their APIs are always a Document). So we have jquery removing these elements and jsom forcefully adding them. Damnit. |
Summarizing this: So I am going to experiment with neutron-html5parser on a branch. |
This one will be fixed with Htmlizer v2. |
Fantastic, thanks for keeping it in mind :) |
Fixed with v2. |
Expected output:
The text was updated successfully, but these errors were encountered: