After integrating the YUI rich text editor, I am looking for a way to automatically remove the <html>
, <body>
, and DOCTYPE
tags from the content when it is saved. Although I can achieve this by parsing the HTML code afterward, I am seeking a more efficient solution.
Currently, the edited text in the YUI editor is saved as:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<body>
<p>foo</p>
</body>
</html>
...but my goal is to save only the following:
<p>foo</p>
Any suggestions on how to achieve this?
P.S.: My implementation of the YUI editor involves using the yui_editor plugin for ruby on rails. However, I would appreciate a general answer applicable to any YUI editor as well!