如何让我的自定义属性变得整洁?

时间:2010-07-12 18:03:41

标签: php html custom-attributes tidy

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>

如何让我的自定义属性变得整洁?

2 个答案:

答案 0 :(得分:1)

我认为一个前导下划线使该属性无效,所以整洁将删除它,即使你告诉他不要删除未知属性。

答案 1 :(得分:0)

原来删除属性名称中的前导下划线可以解决问题 - my_custom_attr正常工作。

相关问题