Using a customConverter to remove font formatting from rich text

<xp:inputRichText id="inputRichText1" value="#{doc.body}" readonly="true">
					var html=value.toString();
					html=html.replace(/<(FONT|font)([ ]([a-zA-Z]+)=(\"|')[^\"\\']+(\"|'))*[^>]+>/g,"")
				       return html;
				       print (e);

This example of a customConverter uses regular expression to remove all occurences of HTML font tags from a rich text field. This can be used to control the formatting of rich text when rendered in the browser.

The code can easily be changed to modify other parts of the HTML formatting.

Per Henrik Lausten
March 27, 2012 8:57 AM

All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.

No comments yetLogin first to comment...