If you a lot of work in a web based rich text editor, you know some of the headaches it causes. One of the most popular is TinyMCE rich text editor which offers a host of optins for styling, adding images, applying classes, font styles and many of the common HTML elements.
One of the things it doesn’t do well is write clean code. Take this example, where a paragraph already has a bit too much styling applied inline, and rules out any styles in your CSS file.
<p style="font: normal normal normal 14px/normal Cambria; margin: 0px">Ten miles north of Westport lies a neighborhood in east Bridgeport where crime is an everyday occurrence and struggling to make ends meet is a way of life. In this neighborhood, on a side street next to a burnt out crack den sits a cheery yellow house offering hope for women and children in the area who want to learn English. </p><p style="font: normal normal normal 14px/normal 'Times New Roman'; min-height: 15px; margin: 0px"></p>
There are 2 icons that look pretty helpful, a broom and an eraser. Oh these are clean up tools.Thinking the buttons labeled “Clean Messy Code” or “Remove Formatting” would create clean, un-styled code resulted in a complete unreadable mess.
Clicking Clean Messy Code resulted with:
<p style="font: normal normal normal 14px/normal Cambria; margin: 0px">Ten miles north of Westport lies a neighborhood in east Bridgeport where crime is an everyday occurrence and struggling to make ends meet is a way of life. In this neighborhood, on a side street next to a burnt out crack den sits a cheeryyellow house offering hope for women and children in the area who want to learn English.</p><p style="font: normal normal normal 14px/normal 'Times New Roman'; min-height: 15px; margin: 0px"></p>
Sweet, no change. Does it even do anything?
Click Remove Formatting resulted with:
<span style="font-size: x-small; font-family: Verdana"> <br />
Ten miles north of Westport lies
a neighborhood in east Bridgeport
where crime is an everyday occurrence
and struggling to make ends meet
is a way of life. In this neighborhood,
on a side street next to a burnt
out crack den sits a cheery yellow
house offering hope for women and
children in the area who want to
learn English. <br />
Oh yeah, that’s really what I wanted. WTF? It’s like Jerry Lewis helping out and things just get worse and worse.