php - Preserve line breaks between images in DomDocument -
consider php code:
$content = '<img />'."\n\n".'<img />'; $doc = new domdocument(); $doc->loadhtml($content); echo $doc->savehtml();
the output (including wrapping html/body etc) gives me:
<img><img>
with no space between images.
calling:
$doc->preservewhitespace = true;
doesn't change anything.
how preserve white space in original html?
answering own question - it's buggy behaviour of old version of libxml2:
https://bugs.php.net/bug.php?id=50278
this issue solved passing libxml_html_nodefdtd option when loading document. constant available of php 5.4.0 when libxml2 >= 2.7.8 used. see http://3v4l.org/qs4tc.
the shared server i'm on uses 2.7.6 not sure helps me, can see if can upgrade. hope helps else.
Comments
Post a Comment