function eqToHTML(equation) { equation = equation.slice(2, -2) .replaceAll(/ /g, '') .replaceAll(/[\/+\*-=:]/g, '$&') .replaceAll(/\\frac{(.*)}{(.*)}/g, '$1$2') .replaceAll(/\^{(.*)}/g, '$1'); equation = equation .replaceAll(/\\frac{(.*)}{(.*)}/g, '$1$2') .replaceAll(/\^{(.*)}/g, '$1'); return '
' + equation + '
'; } for (var par of document.getElementsByTagName('p')) { var eqs = par.innerText.match(/\\\[[^\]]*\\\]/g); if (eqs === null) continue; for (var equation of eqs) { par.innerHTML = par.innerHTML.replace(equation, eqToHTML(equation)); } }