beautify-html icon indicating copy to clipboard operation
beautify-html copied to clipboard

Zero problem

Open GDCReXes opened this issue 5 years ago • 2 comments

Hey nice job! But i got one fail... <span>0</span> will be...

<span></span>

why?

GDCReXes avatar May 14 '19 16:05 GDCReXes

Probably a comparison, somewhere in the Beautifier. I bet passing the unformatted tag option = 'span', could resolve this particular issue for you.

I just popped in to let Ivanweiler know that after a couple days of half-writing my own DOMDocument parser, playing with a few 3rd-party libs, etc. This Lib is like the number 42. Thank you.

BinaryBrother avatar Mar 10 '20 00:03 BinaryBrother

@GDCReXes issue found:

In print_token_raw method replace the if ($text && $text !== '') { with if ($text != null && $text !== '') {

private function print_token_raw($text)
{
    if ($text != null && $text !== '') {
        if (strlen($text) > 1 && $text[strlen($text) - 1] === "\n") {
            // unformatted tags can grab newlines as their last character
            $this->output[] = substr($text, 0, -1);
            $this->print_newline(false, $this->output);
        } else {
            $this->output[] = $text;
        }
    }

    for ($n = 0; $n < $this->newlines; $n++) {
        $this->print_newline($n > 0, $this->output);
    }
    $this->newlines = 0;
}

onesideat avatar Apr 11 '21 10:04 onesideat