paquettg/php-html-parser

how do I get output with linebreaks?

skinofthesoul opened this issue · 0 comments

I'm not sure whether I'm simply not doing this right – hopefully there is an easy fix :-)

I'm using PHPHtmlParser to grab all the images on a page and add a sizes attribute to them. All of this works fantastically, so thank you for that! However, if the page contains inline javascript, that doesn't work anymore afterwards, and it seems to be because all the line breaks are removed. My loading code looks like this:

$dom = new Dom;
$dom->loadStr($this->grav->output, (new Options())->setCleanupInput(false));

And after I've made all the changes and I dump the $dom object, I get the following output:
phphtmlparser

The only HTML I can find is under content, and it has linebreaks. Perfect. However, I can't seem to get it as output? Both $dom->outerHtml and $dom->innerHtml give me the HTML without linebreaks…

What can I do?