Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Blank lines are added when serializing HTML between elements that should not have whitespace #1304
Class AMP_Content_Sanitizer in class-amp-content.php
I've noticed this as well. It's actually an issue with PHP's DOM library (which uses libxml) and the behavior of its HTML serializer. Whitespace is not being preserved exactly. This became a problem for us in one case where the original HTML had two adjoining elements without any whitespace that are laid out side-by-side with
The method in question for where serialization is happening is
That being said, the issue could potentially come down to how
We might need to find a workaround if there isn't something that can be done at the libxml level.
At the same time, for improved performance (by reducing byte size) it would actually be best if whitespace were collapsed and not preserved when serializing. That is, unless the whitespace is inside of a
Glad someone knows what I am talking about. However, only a few of those making AMP pages even bother to look at the html being generated. AMP is a dead duck if you can't even produce clean html from a wordpress editor. We are not even talking about complex html constructs but basic stuff.
This problem occurs not just in this plugin but AMP for WP (https://wordpress.org/plugins/accelerated-mobile-pages/ ) also as it uses the vendor code.
@westonruter sorry - that was probably not called for. What I mean is I don't get these types of issues with Genesis. If I put something in the editor then that is what I get. If I write bad html I get bad html on the output. If I write good html then I get good html. What we have here is good html being turned into broken html (which ever way you look at it). It effects this plugin and another I use - https://wordpress.org/plugins/accelerated-mobile-pages/ . My PHP skills are not good enough to fix it.
Again - sorry for the remark because the Genesis part is irrelevant. Just using a bog standard WP install and I get the same issue.