Skip to content

< in addHTML #791

Closed
Closed
@sleker78

Description

@sleker78

Hi,

Great application - thanks.
There is a problem when you have < in string:

$html='<p>something &lt; something </p>;
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html);

It'll break the xml structure for docs. Possible solution is to change addHTML method:

 // Load DOM
        $dom = new \DOMDocument();
        $dom->preserveWhiteSpace = true;
        $dom->loadXML($html,LIBXML_NOCDATA);

With this replacement user can send <![CDATA[_lt_]]> instead of &lt; like this:

$html='<p>something <![CDATA[_lt_]]> something </p>;
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html);

and it'll work ok.

Maybe there is some better solution but this will work for now.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions