Advertisement
Guest User

Untitled

a guest
Jan 13th, 2023
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. html = $text;
  2. html = html.replace(/<pre(.*?)>(.*?)<\/pre>/gmi, "[code]$2[/code]");
  3.     html = html.replace(/<h[1-7](.*?)>(.*?)<\/h[1-7]>/, "\n[h]$2[/h]\n");
  4.     //paragraph handling:
  5.     //- if a paragraph opens on the same line as another one closes, insert an extra blank line
  6.     //- opening tag becomes two line breaks
  7.     //- closing tags are just removed
  8.     // html += html.replace(/<\/p><p/<\/p>\n<p/gi;
  9.     // html += html.replace(/<p[^>]*>/\n\n/gi;
  10.     // html += html.replace(/<\/p>//gi;
  11.  
  12.     html = html.replace(/<br(.*?)>/gi, "\n");
  13.     html = html.replace(/<textarea(.*?)>(.*?)<\/textarea>/gmi, "\[code]$2\[\/code]");
  14.     html = html.replace(/<b>/gi, "[b]");
  15.     html = html.replace(/<i>/gi, "[i]");
  16.     html = html.replace(/<u>/gi, "[u]");
  17.     html = html.replace(/<\/b>/gi, "[/b]");
  18.     html = html.replace(/<\/i>/gi, "[/i]");
  19.     html = html.replace(/<\/u>/gi, "[/u]");
  20.     html = html.replace(/<em>/gi, "[b]");
  21.     html = html.replace(/<\/em>/gi, "[/b]");
  22.     html = html.replace(/<strong>/gi, "[b]");
  23.     html = html.replace(/<\/strong>/gi, "[/b]");
  24.     html = html.replace(/<cite>/gi, "[i]");
  25.     html = html.replace(/<\/cite>/gi, "[/i]");
  26.     html = html.replace(/<font color="(.*?)">(.*?)<\/font>/gmi, "[color=$1]$2[/color]");
  27.     html = html.replace(/<font color=(.*?)>(.*?)<\/font>/gmi, "[color=$1]$2[/color]");
  28.     html = html.replace(/<link(.*?)>/gi, "");
  29.     html = html.replace(/<li(.*?)>(.*?)<\/li>/gi, "[*]$2");
  30.     html = html.replace(/<ul(.*?)>/gi, "[list]");
  31.     html = html.replace(/<\/ul>/gi, "[/list]");
  32.     html = html.replace(/<div>/gi, "\n");
  33.     html = html.replace(/<\/div>/gi, "\n");
  34.     html = html.replace(/<td(.*?)>/gi, " ");
  35.     html = html.replace(/<tr(.*?)>/gi, "\n");
  36.  
  37.     html = html.replace(/<img(.*?)src="(.*?)"(.*?)>/gi, "[img]$2[/img]");
  38.     html = html.replace(/<a(.*?)href="(.*?)"(.*?)>(.*?)<\/a>/gi, "[url=$2]$4[/url]");
  39.  
  40.     html = html.replace(/<head>(.*?)<\/head>/gmi, "");
  41.     html = html.replace(/<object>(.*?)<\/object>/gmi, "");
  42.     html = html.replace(/<script(.*?)>(.*?)<\/script>/gmi, "");
  43.     html = html.replace(/<style(.*?)>(.*?)<\/style>/gmi, "");
  44.     html = html.replace(/<title>(.*?)<\/title>/gmi, "");
  45.     html = html.replace(/<!--(.*?)-->/gmi, "\n");
  46.  
  47.     html = html.replace(/\/\//gi, "/");
  48.     html = html.replace(/http:\//gi, "http://");
  49.  
  50.     html = html.replace(/<(?:[^>'"]*|(['"]).*?\1)*>/gmi, "");
  51.     html = html.replace(/\r\r/gi, "");
  52.     html = html.replace(/\[img]\//gi, "[img]");
  53.     html = html.replace(/\[url=\//gi, "[url=");
  54.  
  55.     html = html.replace(/(\S)\n/gi, "$1 ");
  56.  
  57.     return html;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement