volca / markdown-preview

Markdown Preview Plus -- Enables Chrome to render markdown files as HTML
https://chrome.google.com/webstore/detail/markdown-preview-plus/febilkbfcbhebfnokafefeacimjdckgl
MIT License
237 stars 73 forks source link

SCRIPT tags should not be processed with KaTeX #128

Closed jackens closed 2 years ago

jackens commented 3 years ago

As in the title

volca commented 2 years ago

can you render the test file ok?

jackens commented 2 years ago

The test file does not have any SCRIPT tag. Please check the example below:

With the following script, links should be able to split on backslash characters, i.e.:
<https://github.com/volca/markdown-preview/issues/128>.
The script sometimes works and sometimes not.
Even when it works, it works with this ugly error:

```
katex parse math string […]

[…]

renderKatex @ diagramflowseq.js:146
```

<style>
body {
  width: 10cm;
  margin: auto;
}
</style>

<script>
var E=Object,A=E.create,C=E.keys,O=Array.isArray,m="";var h={}.toString,u=e=>h.call(e).slice(8,-1);var S=e=>u(e)==="Boolean";var _=e=>e?.nodeType===document.ELEMENT_NODE;var d=e=>u(e)==="Number",a=e=>u(e)==="Object";var T=e=>u(e)==="String",y=e=>e?.nodeType===document.TEXT_NODE;var j=(...e)=>String.raw.apply(0,e).trim().split(/\s+/),g=(...e)=>j.apply(0,e).reduce((t,o)=>(t[o]=void 0,t),A(null));var b="http://www.w3.org/2000/svg",x={svg:b,xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink"},f=({a:e,e:t,i:o,k:n,n:c,p:l,t:p})=>{if(t===void 0?p!==void 0&&(c=c??x[p],t=c!==void 0?document.createElementNS(c,p):document.createElement(p)):(T(t)||d(t))&&(t=document.createTextNode(t)),_(t)){if(a(e))for(let r in e){let i=e[r],s=r.match(/^(.+?):(.*)$/);S(i)?i?s!==null?t.setAttributeNS(x[s[1]],s[2],m):t.setAttribute(r,m):s!==null?t.removeAttributeNS(x[s[1]],s[2]):t.removeAttribute(r):s!==null?t.setAttributeNS(x[s[1]],s[2],i):t.setAttribute(r,i)}if(a(n))for(let r in n){let i=n[r];if(a(i))try{for(let s in i)t[r][s]=i[s]}catch{t[r]=i}else t[r]=i}o!==void 0&&o.forEach(r=>f({n:c,...r,p:t}))}return l!==void 0&&t!==void 0&&l.appendChild(t),{e:t}};var w=g`IFRAME NOSCRIPT PRE SCRIPT STYLE TEXTAREA`,N=e=>{let t=[e];for(;t.length;){let o=t.shift();if(_(o))for(let n of o.childNodes)(y(n)||_(n)&&!(n.tagName.toUpperCase()in w))&&t.push(n);else if(y(o)&&o.nodeValue!==null&&o.nodeValue.trim()!==m){let n=o;o.nodeValue.split(/(\s|\(|„)([aiouwz—]\s)/gi).forEach((c,l)=>{l%=3;let p=l===2?f({t:"span",a:{class:"nbsp"},i:[{e:c}]}).e:l===1?f({e:c}).e:f({e:c.replace(/([/.])(?=[^\s])/g,"$1​")}).e;o.parentNode!==null&&o.parentNode.insertBefore(p,n.nextSibling),n=p}),o.parentNode?.removeChild(o)}}};window.onload=()=>N(document.body);
</script>
volca commented 2 years ago

Can't reproduce any more. Close it. Reopen the issue if you need