Advertisement
fagci

Epsilon notes markdown extra attributes

Oct 14th, 2018
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let regex = /<(\w+)\s*(.*)>([^{>]*)\{([^}]+)\}(.*)/g,
  2.     body = document.body,
  3.     html = body.innerHTML;
  4. body.innerHTML = html.replace(regex, (s,tag,eAttr,bCont, attr, aCont) => {
  5.   let attributes = attr.split(' ').map((part) => {
  6.     return part
  7.       .replace(/^\./,'class=')
  8.       .replace(/^#/,'id=')
  9.       .replace(/^([^=]+)=(.+)$/,'$1="$2"');
  10.   }).join(' ');
  11.   return `<${tag} ${eAttr} ${attributes}>${bCont} ${aCont}`
  12. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement