src/Renderer/Html.php
public function render(bool $trim = false): string
    {
        $this->output = '';

        $block_open = false;

        foreach ($this->deltas as $i => $delta) {
            if (
                $delta->displayType() === Delta::DISPLAY_INLINE &&
                $block_open === false
            ) {
                $block_open = true;
                $this->output .= '<p>';
            }

            if ($delta->isChild() === true && $delta->isFirstChild() === true) {

                if (
                    $block_open === true &&
                    $this->deltas[$i - 1]->displayType() === Delta::DISPLAY_INLINE
                ) {
                    $this->output .= "</p>\n";
                    $block_open = false;
                }

                $this->output .= '<' . $delta->parentTag() . ">\n";
            }

            if (
                $delta->displayType() === Delta::DISPLAY_BLOCK &&
                $block_open === true
            ) {
                $block_open = false;
                $this->output .= "</p>\n";
            }

            $this->output .= $delta->render();

            if (
                $delta->displayType() === Delta::DISPLAY_INLINE &&
                (
                    $block_open === true &&
                    $delta->close() === true
                )
            ) {
                $this->output .= "</p>\n";
                $block_open = false;
            }

            if ($delta->isChild() === true && $delta->isLastChild() === true) {
                $this->output .= '</' . $delta->parentTag() . ">\n";
            }

            if (
                $i === count($this->deltas) - 1 &&
                $delta->displayType() === Delta::DISPLAY_INLINE && $block_open === true
            ) {
                $this->output .= "</p>\n";
            }
        }

        if ($trim === false) {
            return $this->output;
        } else {
            return trim($this->output);
        }
    }
public function render(bool $trim = false): string
    {
        $this->output = '';

        $block_open = false;

        foreach ($this->deltas as $i => $delta) {
            if (
                $delta->displayType() === Delta::DISPLAY_INLINE &&
                $block_open === false
            ) {
                $block_open = true;
                $this->output .= '<p>';
            }

            if ($delta->isChild() === true && $delta->isFirstChild() === true) {

                if (
                    $block_open === true &&
                    $this->deltas[$i - 1]->displayType() === Delta::DISPLAY_INLINE
                ) {
                    $this->output .= "</p>\n";
                    $block_open = false;
                }

                $this->output .= '<' . $delta->parentTag() . ">\n";
            }

            if (
                $delta->displayType() === Delta::DISPLAY_BLOCK &&
                $block_open === true
            ) {
                $block_open = false;
                $this->output .= "</p>\n";
            }

            $this->output .= $delta->render();

            if (
                $delta->displayType() === Delta::DISPLAY_INLINE &&
                (
                    $block_open === true &&
                    $delta->close() === true
                )
            ) {
                $this->output .= "</p>\n";
                $block_open = false;
            }

            if ($delta->isChild() === true && $delta->isLastChild() === true) {
                $this->output .= '</' . $delta->parentTag() . ">\n";
            }

            if (
                $i === count($this->deltas) - 1 &&
                $delta->displayType() === Delta::DISPLAY_INLINE && $block_open === true
            ) {
                $this->output .= "</p>\n";
            }
        }

        if ($trim === false) {
            return $this->output;
        } else {
            return trim($this->output);
        }
    }
public function render ( bool $ trim = false ) : string { $ this -> output = '' ; $ block_open = false ; foreach ( $ this -> deltas as $ i => $ delta ) { if ( $ delta -> displayType ( ) === Delta :: DISPLAY_INLINE && $ block_open === false ) { $ block_open = true ; $ this -> output .= '<p>' ; } if ( $ delta -> isChild ( ) === true && $ delta -> isFirstChild ( ) === true ) { if ( $ block_open === true && $ this -> deltas [ $ i - 1 ] -> displayType ( ) === Delta :: DISPLAY_INLINE ) { $ this -> output .= "</p>\n" ; $ block_open = false ; } $ this -> output .= '<' . $ delta -> parentTag ( ) . ">\n" ; } if ( $ delta -> displayType ( ) === Delta :: DISPLAY_BLOCK && $ block_open === true ) { $ block_open = false ; $ this -> output .= "</p>\n" ; } $ this -> output .= $ delta -> render ( ) ; if ( $ delta -> displayType ( ) === Delta :: DISPLAY_INLINE && ( $ block_open === true && $ delta -> close ( ) === true ) ) { $ this -> output .= "</p>\n" ; $ block_open = false ; } if ( $ delta -> isChild ( ) === true && $ delta -> isLastChild ( ) === true ) { $ this -> output .= '</' . $ delta -> parentTag ( ) . ">\n" ; } if ( $ i === count ( $ this -> deltas ) - 1 && $ delta -> displayType ( ) === Delta :: DISPLAY_INLINE && $ block_open === true ) { $ this -> output .= "</p>\n" ; } } if ( $ trim === false ) { return $ this -> output ; } else { return trim ( $ this -> output ) ; } }
Generate the final HTML, calls the render method on each object

@param boolean $trim Optionally trim the output

@return string
Generate the final HTML calls the render method on each object