function myTidy($content) {
$tidyConfig = array(
'indent' => false, //don't indent
'doctype' => 'omit', //don't include doctype
'wrap' => 0, // don't line wrap
'show-body-only' => true, //don't include <html><head><title><body>
'drop-proprietary-attributes' => false, //this doesn't seem to be helping with our youtube stuff...
);
$tidy = tidy_parse_string($content, $tidyConfig, 'UTF8');
$tidy->cleanRepair();
return (string)$tidy;
}
echo myTidy('<span _my_custom_attr="asdfsdf">asdf</span>'), "\n";
期望的输出
<span _my_custom_attr="asdfsdf">asdf</span>
实际输出:
<span>asdf</span>
如何让我的自定义属性变得整洁?
答案 0 :(得分:1)
我认为一个前导下划线使该属性无效,所以整洁将删除它,即使你告诉他不要删除未知属性。
答案 1 :(得分:0)
原来删除属性名称中的前导下划线可以解决问题 - my_custom_attr
正常工作。