Wikimedia Developer Support

Spoiler extension no longer works because of Tidy parser replaced

mediawiki
extensions

#1

Hello!
I tried to solve this problem for days. I had an older spoiler extension wich worked quite fine. I wanted to continue developing it but it does no longer work anymore as intended. I found no way to make the “tag extension” to be inside a text AND with working wiki text inside the extension without the text above and below resulting in generating own paragraphs.

Practically I want (watch the p-tags). When clicking the button the content of the spoiler-tag is visible. Worked fine before on a older wiki version:

<p>This is some Text.<spoiler title="Test">This is spoiler content with some wiki text. When this button is clickend. This text is visible, as a block element</spoiler> This is some other text.</p>

But what I get is:

<p>This is some Text.</p>
<spoiler title="Test">This is spoiler content with some wiki text. When this button is clickend. This text is visible, as a block element</spoiler>
<p>This is some other text.</p>

Please keep in mind that the results into generating valid HTML. Here I wrote it this way so you can visualize it better. I have found out that that Tidy is replaced with an HTML 5 parsing algorithm.
I tried almost everything. I replaced all div tags of my extension with spans (not semantic HTML) because only this way the button stays inline and no p tags is wrapped before and after the spoiler button. That is not a CSS problem because display: inline-block; is set. The problem ist the parser. I tried all possible code I have found on mediawiki docs. Some of them (and in combination):

$striped_text = $parser->killMarkers( $render );
$render = $parser->recursiveTagParse($striped_text);
$render = $parser->insertStripItem($render, $parser->mStripState);

Much greetings.


#2

Is the extension outputting an actual <spoiler> tag?


#3

No, it converts correctly into a bunch of spans. The markup is generated in a render() method.


#4

I don’t understand your examples then, the tidy step should be running after extension markup has been converted to HTML, so it never sees the <spoiler> tag.