Forums | Mahara Community
Fix for "phantom bullet" in TinyMCE - a good one?
05 October 2011, 5:35 PM
I'm posting this issue/solution here to see if my provider's solution is a good one...at his request. If the solution is validated, we'll apply it to the production server. If not, I'm open for alternatives.
I recently noticed in v1.4 with nested unordered lists, where the indented bullet has two bullets on the line, as here, on the production server:
This only shows up on the rendered page...preview looks fine.
Here is the analysis and solution from my freelance developer...his solution works - see here on the test server:
But I think this would be called a hack, and therefore harder to maintain...thoughts from anyone?
And why did this show up only recently? I haven't had this issue in applications like pbwiki which also uses TinyMCE.
The problem here is being caused directly by htmlpurifier. On rendering, the purifier is wrapping sub lists (ul, ol) with list tags (li). It does this because its job is to remove malicious code and to generate XTHML compliant code.**
This is very unfortunate, because while it may now be nicely compliant with standards, we get the rogue list item and its bullet.
As far as I can see (I may be wrong), there is no way to style this bullet off the page using CSS. This is because we aren't able to access the content to apply a class or ID to the sub items.
The only solution I can see involves a patch to the core htmlpurifier code:
- adding a new option to the HTML Purifier to choose between valid and invalid list nesting
- applying this new option in /lib/web.php to turn on invalid list nesting
I have written this patch and tested it on the staging site - it seems to work.
I think it would be a good idea to approach the core team with this solution and get some feedback.
05 October 2011, 7:56 PM
Have you tried to replace your tinymce with the current version? I think that we should rule out a bug that might already be fixed in TinyMCE's current version.
There is a configuration settings "fix_list_elements". That configuration is turned off by default. Have you tried to turn it on to see if that fixes your problem?
06 October 2011, 7:44 AM
I don't think it's an issue with tinymce - that layout renders fine in the editor. The problem only comes on rendering to the page via the 'clean_html' function which invokes the purifier.
06 October 2011, 9:49 AM
Just tested it.
Adding the following line to the web.php file fixes the problem (tested in TinyMCE 3.4.6):
fix_list_elements : true,
The bugs I added that are related to TinyMCE I added the tag TinyMCE, so they can be all added at once.
06 October 2011, 11:46 AM
Thanks Melissa, very helpful! A slick solution that we will apply.
If this can make it into core, that will be easier to maintain.
07 October 2011, 3:44 AM
One way to speed up things making it into core Mahara that are in review is to test them (as you've already done ) and to give your approval in the Mahara review system. Only a select number of experienced Mahara developers can perform a code review, but you can still give your stamp of "verified" approval. No specific technical knowledge is needed for that except for knowing how to get the code into your testing environment. As you encountered the problem first-hand, you will know how to reproduce it best.
09 October 2011, 6:17 PM
Small correction: everybody is able to give a code review of -1 or +1 (-2 and +2 being reserved for members of the Mahara Reviewers team) but the Verified option is restricted to people who are members of the Gerrit testing group.
06 October 2011, 9:41 PM
Thanks for the solution Melissa. I have created a patch for it: