http://qs321.pair.com?node_id=554145

guha has asked for the wisdom of the Perl Monks concerning the following question:

I have a webapplication where the users can add information to a textArea. To make it a bit more spiffy I added a JavaScript application which is a sort of crippled HTML editor. This is all fine and dandy, but then I noticed that the users were cut&pasting from Word directly. This has two drawbacks.

* The HTML from is extremely wordy, heh, a rather simple table can generate megabytes of HTML

* The HTML is too complex for the javascript application.

A possible solution to this problem would be if I could somehow simplify the pasted HTML when saving it to the DB.

Something like take this very complex HTML and allow only tables, bold, italic, h1,h2, plain text, ... and remove everything else. This would change the WYSIWYG but not the content.

I have tried to, using regexps, remove certain specific Word-HTML constructs. This has the advantage of decreasing the size of the resulting HTML but seems to destabilize stuff as well.

Ideas, pointers to CPAN, anyone ?