-
-
Notifications
You must be signed in to change notification settings - Fork 905
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
Nokogiri does not honor leading whitespace in some cases #319
Comments
Also, perhaps you'll say to just do this instead:
That's fine, but what about this:
Results in this:
Can't do Node#content() there, and anyway it gets complicated. |
The root of this issue is that we strip the tags before creating a DocumentFragment (which is then inserted into the document in the right place). This stripping is done largely for historical reasons at this point. DocumentFragments used to be a niche use case, but have since become the core of nearly every node-creation API call, and so maybe we should revisit this convention for 1.5. |
Yeah, currently the only workaround I've found is to set it twice. It's pretty goofy.
Because naturally each way of setting content works differently. ;-) |
{XML,HTML}::DocumentFragment.{new,parse} no longer strip leading and trailing whitespace. Closed by bbebdcc. |
Look at this weirdness!
And this is the output:
But it should be this instead, right?
Maybe you don't consider this a bug for some reason. If not, it would be nice to at least have the ability to set something like :preserve_whitespace => true on the parent node, or pass it in an options hash to Node#add_child() or something.
This is Nokogiri 1.5.0.beta.1 (gem), by the way.
Thanks!
The text was updated successfully, but these errors were encountered: