I am using a utility called FresherEditor which uses the ContentEditable plugin for jQuery to create an editable document in the browser window. I then need to take that output and generate SVG graphics from the rules obtained by parsing the HTML governed style into CSS.
The freshereditor will produce output that looks somewhat like:
<div>
<p>
<i>
<u>
<b>
<font face="Verdana">
Hello, World!
</font>
</b>
</u>
</i>
</p>
</div>
When what I would prefer is something that looks like:
<div>
<p style="font-weight: bold; font-style: italic; text-decoration: underline; font-family: Verdana;">
Hello, World!
</p>
</div>
Any suggestions would be helpful.
This was a very fun problem; thanks! Following are scripts that add
html2style()andstyle2html()methods. The test case shows that you can convert between the two with no visual change (though the ordering of the element nesting may be different after a round trip).Test Case Showing These Working
http://jsfiddle.net/GaPBS/
Converting Nested HTML Phrase Elements to Style Attributes
Converting Style Attributes to Nested HTML Phrase Elements