Closed
Description
I am currently using PHPHtmlParser in conjunction with WordPress. WordPress stores structured data in the database as HTML comments, so it's important that I'm able to round-trip HTML with the comments left intact.
The default behavior of PHPHtmlParser is for comments to be stripped (the cleanupInput option is set to true) and if I set setCleanupInput to false I get a strange "close comment" output. See below for how to replicate. This is for version 3.0.1.
Script
<?php
require 'vendor/autoload.php';
use PHPHtmlParser\Dom;
use PHPHtmlParser\Options;
$html = '<!-- testing -->';
echo "input:\n";
var_dump($html);
$dom = new Dom();
$dom->loadStr($html);
echo "test 1:\n";
var_dump($dom->innerHtml);
$options = new Options();
$options->setCleanupInput(false);
$dom->setOptions($options);
$dom->loadStr($html);
echo "test 2:\n";
var_dump($dom->innerHtml);
Result
input:
string(16) "<!-- testing -->"
test 1:
string(0) ""
test 2:
string(22) "<!-- testing --></!-->"