-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
preserveWhiteSpace not supported #23
Comments
In my experience Do you have any example code that behaves differently (related to whitespaces) in DOMDocument and HTML5DomDocument? |
No I don't have an example that shows a difference. I'm not using the PHP DOMDocument. I've written something else to reduce whitespace in text nodes now. And it can do so more intelligently, only where it's safe to do so. It doesn't appear to take considerable time or memory. |
Do you have the code in GitHub? Will be happy to take a look and possibly improve preserveWhiteSpace in HTML5DOMDocument. |
https://gist.github.com/ygoe/065aceb90f9efd81e8f57ee01546b5f7 The code shows how I minify HTML manually. It may not be 100% safe but has worked for me so far. And it still leaves single spaces in places where they're not necessary. But that probably only decides at rendering time together with the stylesheet. Instead of the minify code block, the |
I have the same problem with some unit-test (by replacing DOMDocument) and I think that the new "saveHTML()" method removes some "\n", or? |
A reason, perhaps, that this is not working, is that
Fixing this is not really easy because of the fixed substr()s after this code. |
Just wondering why this doesn't produce "minified" HTML output:
HTML5DOMDocument inherits from DOMDocument and that should have the preserveWhiteSpace property. It defaults to true and according to numerous Stack Overflow answers, setting it to false produces output without whitespace-only text nodes, like indenting. It doesn't change my HTML in any way however.
The property does exist, is initially true, and is no longer true after setting it to false. It just has no effect here.
The text was updated successfully, but these errors were encountered: