手册:$wgUseTidy
此功能已在版本1.33.0中,从MediaWiki核心代码中移除。 请参见$wgTidyConfig以获取使用此功能的替代方式。 |
Tidy: $wgUseTidy | |
---|---|
使用Tidy确保输出的HTML正常。 |
|
引进版本: | 1.3.0 |
弃用版本: | 1.26.0 (Gerrit change 235401; git #2c6c954e) |
移除版本: | 1.33.0 (Gerrit change 467972; git #6db35b3c) |
允许的值: | (布尔值) |
默认值: | false |
其他设置: 按首字母排序 | 按功能排序 |
细节
使用“HTML Tidy”确保输出的HTML正常。
HTML Tidy是一个修复错误HTML的自由工具。 参见w:HTML tidy和http://www.w3.org/People/Raggett/tidy/
You may wish to setup this tool, and set $wgUseTidy=true
, to ensure that the wiki outputs reasonably clean and compliant HTML, even when malicious or foolish users add corrupt/badly formatted HTML to wiki pages.
Note that MediaWiki already does some built-in checks and corrections to user's HTML, and limits the range of HTML tags and attributes which can be used (unless you set $wgRawHtml =true
Dangerous!)
Limitations are described at 帮助:维基文本中的HTML .
The logic for this is found in includes/Sanitizer.php.
As such, you may decide that running HTML tidy over the output is not necessary.
[[Link|<div>Text</div>]]
will not actually produce a clickable link. There are several dozen particular bugs identified that are likely never to be fixed (see 工單T4542 and its list of blockers). If you enable Tidy, you're in for a world of hurt.
配置
The location of the tidy configuration file can be set using $wgTidyConf - before MediaWiki 1.10, this was required. In later versions, a working default is provided.
但是,这不一定总是可用。 参见$wgTidyInternal 以了解更多安装信息。
效果
Tidy is still required to mix wiki table and HTML table syntax, as well as simple wikicode and html-style markup.
範例 | 代码 | 没有Tidy的解析器 | Tidy |
---|---|---|---|
Mixed nested tags. | {|
|| foo
<tr><td>bar</td></tr>
|}
|
<table>
<tr>
<td> foo
<p><tr><td>bar</td></tr></p>
</td></tr></table>
|
<table>
<tr><td>foo</td></tr>
<tr><td>bar</td></tr>
</table>
|
Mixed open/close tags. | '''foo</b>
|
<b>foo</b></b>
|
<b>foo</b>
|
Definition list nesting | ; hi
:# one
|
<dl><dt> hi
<ol><li> one</li></ol>
</dt></dl>
|
<dl><dt>hi</dt><dd>
<ol><li>one</li></ol>
</dd></dl>
|
<table><tr></td></table>
However, it does not resolve all strict XHTML validation issues, such as duplicate xml ID attribute values, or IDs starting with numbers.