My goal is to add "
around attributes that are missing them, using JavaScript.
For example:
<a class=external title=Title href="http://www.google.com" rel=external>My link</a>
Should become:
<a class="external" title="Title" href="http://www.google.com" rel="external">My link</a>
Also:
<a target=_blank href="http://www.google.com">My link</a>
Should be changed to:
<a target="_blank" href="http://www.google.com">My link</a>
In essence - any attribute without "
should be provided with it.
Any thoughts? I believe regex could be the solution?
EDIT: This task is necessary because the HTML is generated by a wysiwyg-editor, and needs to be compliant with a CMS that requires valid XHTML.