How to use the DETAILS html tag in forums?

How to use the DETAILS html tag in forums?

by Peter Diedrichs -
Number of replies: 3
Picture of Particularly helpful Moodlers

When I use the details html tag, to be able to have a "Show all" button in the post, this gets stripped away in forums. It works on Page, Book etc. In Atto it shows as expected in preview, but gets stripped away when posting. This code can hardly be malicious, I think.

Can I somehow make this work? I'm using Moodle 3.8.6.

The code I'm using:

<p>Spoiler alert! If you click "Show all" the movie ending will be revealed.</p>
<details> <summary>Show all</summary>
<p>The full content</p>
</details>
Average of ratings: -
In reply to Peter Diedrichs

Re: How to use the DETAILS html tag in forums?

by Ray Hinton -

I think the Forum HTML cleaning is just more aggressive, and it's probably a combination of security plus Moodle HQ philosophy. For example, the following setting description suggests that indeed some content is treated differently than others in terms of what is stripped. Philosophically, allowing certain kinds of HTML behavior in Forum posts could lead to user confusion, or otherwise a bad experience. Of course other forum modules out on the internet have this kind of feature, but since it's not a thing in Moodle, people might not expect it. I'm not defending that philosophy, just speculating. smile

"Experimental settings

Content cleaning everywhere forceclean
Default: No

Content added to the site is normally cleaned before being displayed, to remove anything which might be a security threat. However, content is not cleaned in certain places such as activity descriptions, page resources or HTML blocks to allow scripts, media, inline frames etc. to be added. If this setting is enabled, ALL content will be cleaned. This may result in existing content no longer displaying correctly."

If you are feeling adventurous, "Enable trusted content - enabletrusttext" in Site security settings may allow more HTML tags through in Forum posts. Definitely read the description. Further than that, you could probably hack it in the Moodle source code, but I'll leave that to someone else!

Average of ratings: Useful (1)
In reply to Ray Hinton

Re: How to use the DETAILS html tag in forums?

by Peter Diedrichs -
Picture of Particularly helpful Moodlers
Thank you. Yes, I guess the forum cleaning is more agressive. It would be great to be able to have a "white list" of code to be allowed.
In reply to Peter Diedrichs

Re: How to use the DETAILS html tag in forums?

by Ray Hinton -
That would certainly be a more elegant solution! (although not without its own challenges, I imagine.)

I my own additional searching, I did see people mention achieving this effect with the Generico filter: https://moodle.org/plugins/filter_generico

But then you have the tradeoff of installing an entire new plugin just to get a single text effect.