List of utility methods to do String to HTML Convert
toHtml()String.prototype.toHtml = function () { var s = this; s = s.replace(/\n/g, '</p><p>'); s = '<p>' + s + '</p>'; s = s.replace('<p></p>', ''); return s; | |
toHtml()String.prototype.toHtml = function() { return this.replace(/<|>/ig, function(m){ return '&'+(m =='>'?'g':'l')+'t;'; }) | |
toHtml()String.prototype.toHtml = function () { var s = this; if (s.indexOf("://") > 0) { s = s.replace(/(^|[^\"\'\]])(http|ftp|mms|rstp|news|https)\:\/\/([^\s\033\[\]\"\']+)/gi, "$1[url]$2: s = s.replace(/\[url\](http\:\/\/\S+\.)(gif|jpg|jpeg|png)\[\/url\]/gi, "[img]$1$2[/img]"); if (s.match(/\[(\w+)([^\[\]\s]*)\].*\[\/\1\]/)) { s = s.replace(/\[url\](.+?)\[\/url\]/gi, "<a href=$1 target=_blank>$1</a>"); s = s.replace(/\[img\](.+?\.(?:gif|jpg|jpeg|png))\[\/img\]/gi, "<img src='$1' alt='$1'>"); ... | |
toHtmlString()String.prototype.toHtmlString = function() { return this.replace(/"/g, '"'); }; |