gpt4 book ai didi

php - Tidy 破坏 anchor hrefs

转载 作者:行者123 更新时间:2023-12-05 05:27:20 27 4
gpt4 key购买 nike

我有以下 HTML 代码(我无法更改它,它来自外部源)

<a href="http://linkhref.com"><center>Link Text</center></a>

但是在使用 tidy 处理之后,HTML 被破坏了( anchor 不可点击,因为 innerHTML 附加在标签之后 :(我正在使用以下配置选项:

$config = array(
'output-xml'=>true,
'wrap'=>false,
'doctype'=>'omit',
'quote-nbsp'=>false,
'quiet'=>true,
'bare'=>true,
'fix-backslash'=>false,
'indent-cdata'=>false
);

tidy 会输出:

<html> 
<head>
<title></title>
</head>
<body>
<a href="http://linkhref.com"></a>
<center>Link Text</center>
<br />
</body>
</html>

有什么建议吗?非常感谢。

最佳答案

理想情况下,无论如何您都不希望保留“center”标签 - 它在 HTML4 中已被弃用,并且在 HTML5 中不再受支持。

尝试添加配置选项:

'clean' => true

关于php - Tidy 破坏 anchor hrefs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20000843/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com