Manual:$wgUseTidy
From MediaWiki.org
| Tidy: $wgUseTidy | |
|---|---|
| Use tidy to make sure HTML output is sane. |
|
| Introduced in version: | 1.3.0 |
| Removed in version: | still in use |
| Allowed values: | (boolean) |
| Default value: | false |
Other settings: Alphabetical | By Function
Contents |
[edit] Details
Use "HTML tidy" to make sure HTML output is sane.
HTML tidy is a free tool that fixes broken HTML. See Wikipedia:HTML tidy and 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 malicous 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 meta:Help:HTML in wikitext. 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.
[edit] Configuration
The location of the tidy configuration file can be set using Manual:$wgTidyConf - before MediaWiki 1.10, this was required. In later versions, a working default is provided.
[edit] Effects
[edit] 1.11 and Parser_OldPP
In the MediaWiki preprocessor in versions 1.11 and earlier (and optionally available via $wgParserConf in 1.12). Tidy is required for complex HTML tag hierarchy in wikicode. HTML tags that are distributed (via transclusion), conditional (via parserfunctions) and mixed (wikicode/HTML) become escaped without Tidy. In the new preprocessor these are handled correctly without Tidy. Examples:
| example | code | 1.11 and OldPP | 1.12 or Tidy |
|---|---|---|---|
| Distributed. Where Template:Opendiv -> <div> and Template:Closediv -> </div>. |
{{opendiv}}foo{{closediv}}
|
<div></div>foo</div> |
<div>foo</div> |
| Conditional/optional. |
{{#if:1|<div>}}foo{{#if:1|</div>}}
|
<div></div>foo</div> |
<div>foo</div> |
[edit] All versions
Tidy is still required to mix wiki table and html table syntax, as well as simple wikicode and html-style markup.
| example | code | OldPP and NewPP without 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> |
Tidy can correct most bad HTML, which can be bad user input like <table><tr></td></table> or conflicting or badly written extensions (and even some bugs in the core software). However, it does not resolve all strict XHTML validation issues, such as duplicate xml ID attribute values, or IDs starting with numbers.