Alex_Rabolin sought help to open a modal window from a Discourse post, but the HTML attribute for="modal-one" was being stripped due to Discourse’s security sanitization. Initially, Alex tried modifying the core markdown.js file directly — which is not recommended — and asked if Discourse.Markdown.whiteListTag('label', 'for', 'modal-one') was correct. fefrei advised creating a plugin instead, and Mittineague corrected the syntax: the third parameter must be a regex, e.g., /modal-one/, not a string. With their help, Alex successfully built a plugin (available on GitHub) to whitelist the attribute. Later, Johani noted that modals can now be rendered directly via themes or theme components without plugins, referencing this guide. The issue was resolved through community collaboration and proper plugin development practices.
I wish I could open this modal window from a post but the problem is, post does not accept this css tag :
for=“modal-one” and automatically clears it.
Here is the html that I’ve put in the post :
<label for="modal-one"><a >News</a></label>
Can you help me , it is a way to gain acceptance for = " modal -one " in a post without whatsoever erase, to force the CSS to just accept this tag for = “” .
Thank you in advance for your help and sorry for my bad english.
Hello , I advance a little on my problem and I think I found the solution, but I can not put in a pratique.
I need help.
All my tests are performed locally on my mac and not on the server.
I think the solution is here: https://meta.discourse.org/t/whitelisting-some-html-tags/24280
But I don’t understand how.
I have edited the file: “/var/www/discourse/app/assets/javascripts/discourse/lib/markdown.js”
and add this line : Discourse.Markdown.whiteListTag(‘label’, ‘for’, ‘modal-one’);
But for="modal-one" disappears again in tag
I write : <label for="modal-one"><a >News</a></label> in the post and the inspector gives that : <label><a>News</a></label>
Thanks very mutch fefrei.
Just ,do You think my line is correct for resolve the problem in making a little plugin : Discourse.Markdown.whiteListTag(‘label’, ‘for’, ‘modal-one’); ?