Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TinyMCE writes terrible HTML!

I've currently got TinyMCE incorporated into the backend editor of a simple blogging/page-editing app, but I'm extremely unhappy with the HTML code it creates. It does all sorts of messy things like:

  • Adding inline style information to span tags that you can't ever find to get rid of without editing the HTML directly.
  • Nesting tags in nonsense ways (e.g. <p><strong><p><span>some text</span></p><strong></p> just to make something bold.)
  • Adding empty <p>&nbsp;</p> lines where they don't belong and I'm not trying to create blank lines.

EDIT: I've looked at lists of the other editors out there (including on SO), but I want to know if people firsthand have had better luck getting clean code out of their wysiwyg editors.

Any recommendations for one that outputs better code behind the scenes?

like image 485
Gabriel Hurley Avatar asked Aug 27 '09 21:08

Gabriel Hurley


2 Answers

How about a rather drastic alternative, and using a WYMIWYG (What You Mean is What You Get) editor rather that another WYSIWYG editor. That way the author is in full control of the schematic markup as well as the content he/she is entering.

Unfortunately I haven't found one that is as feature rich and usable as tinyMCE, but it seems to have come a long way - see http://www.wymeditor.org/demo/

like image 198
Vdex Avatar answered Nov 15 '22 09:11

Vdex


Use HTML purifier before saving the content into the database.

HTML Purifier

like image 41
astropanic Avatar answered Nov 15 '22 11:11

astropanic