views:

69

answers:

1

For a rich text editor that has to handle pasted HTML code from MS Office applications, I'm looking for a Java library that cleans up the content of all "style" attributes in HTML elements, so that only some CSS attributes are left:

  • background-color
  • border
  • color
  • font-family
  • font-weight
  • font-style
  • list-style-type
  • text-align
  • text-decoration
  • vertical-align

For creating a well-formed HTML document, I can use JTidy. For HTML element transformations (removing unwanted elements), I can use http://htmlparser.sourceforge.net/

Is there anything comparable for CSS attributes?

A: 

Try using a some CSS parser (like http://cssparser.sourceforge.net/) and SAC.

lexicore