Extension talk:HTMLPurifier

Add topic
From mediawiki.org

Is the $wgRawHtml parameter still set to false after extension install?[edit]

The extension works fine after installation, the question is which html tags are allowed after installation and if the parameter $wgRawHtml is still set to false or if the extension changes its value to true. Pspviwki (talk) 13:04, 15 June 2023 (UTC)Reply

@Pspviwki Hi! Neither. This extension defines a new <html> extension tag. Perhaps a bit confusing, maybe I should rename it to <purifiedhtml> or something. Sophivorus (talk) 16:54, 15 June 2023 (UTC)Reply
Thanks. Makes sense. I use MW to the limits and this extension solves a few problems with those limits. I assume that what tags are enabled by this extension and allowed beyond the limits of MW is defined by the defaults of html purifier. I guess if I want have the same set of tags as defined in mw:Help:HTML in wikitext and only several tags/attributes beyond these I should define MW set and those few extra tags/atributes in $wgHTMLPurifierConfig. Then whatever changes in config defaults on HTMLPurifier side will not break anything on wiki. Pspviwki (talk) 20:47, 15 June 2023 (UTC)Reply
@Pspviwki If I understand you correctly, then yes, $wgHTMLPurifierConfig seems like the way to go. Good luck, and let me know of any insights! Sophivorus (talk) 22:21, 15 June 2023 (UTC)Reply

Possibility of use in templates with parameters?[edit]

HtmlPurifier extension is in production on 1K pages, MW 1.39.4, both php 7.4 and 8.1, working smoothly. A couple of questions from use.

Template use

<html> tags can be hardcoded in the template and the template called from the page, that works fine.

Attempts with the variable parsing inside the template were not successful, neither attempts of passing html code in template variable. Are things like below possible?

{{Template|variable containing part of html code}}

variable could theoretically contain all characters including = " - & ? _ / \ < >

Template
<html>
html code
{{{variable containing part of html code}}}
html code
</html>

Would that be possible? Thanks. Pspviwki (talk) 15:17, 12 September 2023 (UTC)Reply

@Pspviwki Hi! I think you have to do it like this {{#tag:html|{{{1}}}}} instead of <html>{{{1}}}</html> Sophivorus (talk) 16:00, 12 September 2023 (UTC)Reply
The variable is not parsed. For example if template contains <span class="plainlinks">{{#tag:html|{{{1}}}}}</span> and is called from another page like {{template|<a href="https://test link/>}}, the result is displayed on the page calling the template as {{{1}}}. Pspviwki (talk) 17:56, 12 September 2023 (UTC)Reply
@Pspviwki I just tried it here and it worked. Apparently you need to use named parameters. Sophivorus (talk) 19:23, 12 September 2023 (UTC)Reply
Thanks. It works this way. Great extension to this extension. Pspviwki (talk) 20:01, 12 September 2023 (UTC)Reply