Last modified: 2010-05-15 15:48:27 UTC
If you include a template using {{templatename}}, open HTML-Tags are closed automatically. I have 2 templates, the first opens the tag, the second should close them, but the tags are already closed directly after first included. REPRODUCE: Step1: create 2 templates template1: "setlist_start", content is: "<div style='...'><div style='...'>" template2: "setlist_end", content is: "</div></div>" Step2: create a (new) wiki-page with content: ----- {{setlist_start}} This should be inside the divs! {{setlist_end}} ----- RESULT: the tags of the start-template are closed directly, so the div are not around the content. ----- <div style='...'><div style='...'></div> </div> This should be inside the divs!<p></div> </div> </p> ----- EXPECTED: the tags are not automatically closed! ----- <div style='...'><div style='...'> This should be inside the divs! </div></div> ----- Maybe this can be solved by including another tag to the template like the "<noinclude>" tag, e.g. "<leavetagsopen>" or sth.
I still see this in 1.8.2 and fixing it would be a big help to those wishing to create Wikipedia style portals on their site without having to install and run HtmlTidy.
This site: http://mail.wikipedia.org/pipermail/mediawiki-l/2006-January/009858.html also has a good write up about the bug.
I find Brion's comment there interesting: > IIRC, there's a bug in the parser cleanup when HTML Tidy is enabled which causes > it to _not_ close the open tags for each template. Why would this be intended behavior? Is there a problem with not closing tags automatically before transclusion, only after?
I don't think that it is intended behavior. The nature of the bug seems not to affect Wikipedia (or any other site using MediaWiki) only as a result of having HTML Tidy enabled. However, if being able to open a div tag with one template and close it with another (as is used on all Wikipedia portal pages) is acceptable usage, then it should work regardless of whether HTML Tidy is turned on or off.
The problem is that Sanitizer::removeHTMLtags() fulfills two roles: to clean up the whole document when called from Parser::internalParse(), and to clean up template output when called from Parser::braceSubstitution(). It is not necessary to close HTML tags opened in templates -- any attempt to do so would break thousands of templates on Wikipedia and elsewhere. The fact that this does not work on default installations is counterintuitive and is the source of many complaints. Template syntax is not versatile or complete enough to allow generation of enclosing boxes such as tables, table rows and divs. In my opinion, template expansion should properly be a preprocessing step, unaware of non-template syntax details (except for HTML-style extension tags). removeHTMLtags() should be done once only: after replaceVariables() completes.
Just an fyi to anyone else who runs into this situation. In an extension that I wrote, I was calling a pre-defined template on my site that included wikitext table chars ( {|, |-, |}, etc), and then I was trying to run it through $wgOut->addWikiText. It wouldn't convert the characters to their HTML equivalents. So, instead of converting |- to a "tr" tag, it would just insert |- into the page. Tim looked into it, and said that it was being caused by this bug.
(In reply to comment #5) > In my opinion, template expansion should properly be a preprocessing step, > unaware of non-template syntax details (except for HTML-style extension tags). > removeHTMLtags() should be done once only: after replaceVariables() completes. > This has been implemented with the new preprocessor. Marking as FIXED