HTML-ifying Text in SharePoint

This has probably been done to death, but here’s my version of how to “HTML-ify” HTML text in SharePoint calculated fields into rendered HTML using jQuery:

Perhaps the most interesting part of this script is the regular expression used to capture the HTML tag. Unlike other versions I’ve seen, it easily handles any HTML tag and will match-and-replace even elements that don’t start and end with HTML tags (your content can have leading and trailing text or other HTML). This is exceedingly useful if your calculated field contains textual content or if you need to HTML-ify some string that is rendered in say the newsletter list style.

Specify your selectors wisely to minimize the number of elements to scan.

Here it is again in a “best practices” format hooked up to a simple namespace:

You should be able to copy/paste that and run it.

You may also like...