是否可以让 htmlpurifier 使用 html5 文档类型?
此处的文档声明您可以使用以下内容更改文档类型和编码:
<?php
require_once '/path/to/htmlpurifier/library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
$config->set('Core', 'Encoding', 'ISO-8859-1'); // replace with your encoding
$config->set('HTML', 'Doctype', 'HTML 4.01 Transitional'); // replace with your doctype
$purifier = new HTMLPurifier($config);
$clean_html = $purifier->purify($dirty_html);
?>
但随后在此处的安装说明中指出支持的文档类型为:
256 Other supported doctypes include:
257
258 * HTML 4.01 Strict
259 * HTML 4.01 Transitional
260 * XHTML 1.0 Strict
261 * XHTML 1.0 Transitional
262 * XHTML 1.1
是否可以执行以下操作以允许 html5 doctype?
<?php
require_once '/path/to/htmlpurifier/library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
$config->set('Core', 'Encoding', 'UTF-8'); // replace with your encoding
$config->set('HTML', 'Doctype', 'html5'); // replace with your doctype
$purifier = new HTMLPurifier($config);
$clean_html = $purifier->purify($dirty_html);
?>
还是有其他方法?