Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- javascript: /*BBCode2HTML v1.0.1*/
- ((b, pt, e) => {
- pt = t => {
- var u, h, s = t.data.replace(/\[(\/?)([a-z]+|\*)(?:=([^\]]+))?\]/gi, (s,a,b,c) => {
- switch (b.toLowerCase()) {
- case "b":
- case "br":
- case "center":
- case "code":
- case "i":
- case "quote":
- case "s":
- case "u":
- h = true;
- return `<${a}${b}>`;
- case "color":
- case "size":
- h = true;
- if (a) {
- return '</font>'
- } else return `<font ${b}="${c}">`;
- case "img":
- h = true;
- if (a) {
- return '" />'
- } else return '<img src="';
- case "list":
- h = true;
- if (a) {
- u = false;
- return '</ul>'
- } else {
- u = true;
- return '<ul>'
- }
- case "*":
- if (u && !a && !c) return h = '<li>';
- return s;
- case "url":
- h = true;
- if (a) {
- return '</a>'
- } else return `<a href="${c}">`;
- default: return s;
- }
- });
- if (h) {
- e.innerHTML = s;
- s = t.nextSibling; u = t.parentNode;
- u.removeChild(t);
- while (e.firstChild) u.insertBefore(e.firstChild, s)
- }
- };
- e = document.createElement("DIV");
- (function pe(e, i, n) {
- for (i = e.childNodes.length - 1, n = e.childNodes[i]; i >= 0; i--) {
- switch (n.nodeType) {
- case Node.ELEMENT_NODE: pe(n); break;
- case Node.TEXT_NODE: pt(n)
- }
- }
- })(b)
- })(document.body)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement