Skip to content

Instantly share code, notes, and snippets.

@codequistador
Created June 10, 2015 17:43
Show Gist options
  • Select an option

  • Save codequistador/c66c263da21f6fe4aee2 to your computer and use it in GitHub Desktop.

Select an option

Save codequistador/c66c263da21f6fe4aee2 to your computer and use it in GitHub Desktop.
R and TM get Sup
//Ensure all registered marks and trademarks have sup tags!
$('body *').contents().filter(function () {
if (((this.nodeType == 3) && this.nodeValue.match(/(®|™)/))) {
if (!$(this).parent().is('sup')) {
var newText = [];
$.each(this.nodeValue.split(" "), function (k, text) {
newText.push(text.replace(/(®|™)/, "<sup>$1</sup>"));
});
if (newText.length > 0) {
var html = $(this).parent().html().replace(this.nodeValue, newText.join(" "));
$(this).parent().html(html);
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment