/* HTML Clean for jQuery Anthony Johnston http://www.antix.co.uk version 1.4.2 $Revision$ requires jQuery http://jquery.com Use and distibution http://www.opensource.org/licenses/bsd-license.php 2010-04-02 allowedTags/removeTags added (white/black list) thanks to David Wartian (Dwartian) 2010-06-30 replaceStyles added for replacement of bold, italic, super and sub styles on a tag 2012-04-30 allowedAttributes added, an array of attributed allowed on the elements 2013-02-25 now will push non-inline elements up the stack if nested in an inline element 2013-02-25 comment element support added, removed by default, see AllowComments in options 2013-08-22 removeTagsAndContent added, an array of tag names to do just that 2016-03-11 allowBreakAsLastChild added, 2016-03-15 jshint recommendations, no functional changes */ (function ($) { $.fn.htmlClean = function (options) { // iterate and html clean each matched element return this.each(function () { if (this.value) { this.value = $.htmlClean(this.value, options); } else { this.innerHTML = $.htmlClean(this.innerHTML, options); } }); }; // clean the passed html $.htmlClean = function (html, options) { options = $.extend({}, $.htmlClean.defaults, options); options.allowEmpty = tagAllowEmpty.concat(options.allowEmpty); var tagsRE = /(<(\/)?(\w+:)?([\w]+)([^>]*)>)|