zerodevx / zero-md

Ridiculously simple zero-config markdown displayer
https://zerodevx.github.io/zero-md/
ISC License
437 stars 48 forks source link

Is there a way to use mathjax while still supporting shadow dom? #89

Closed RootofalleviI closed 1 year ago

RootofalleviI commented 1 year ago

As title.

zerodevx commented 1 year ago

Not at the moment unfortunately - at least not without a tonne of customisation code like overriding the render() function.

<head>
  <script defer src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
  <script type="module">
    import { ZeroMd } from 'https://cdn.jsdelivr.net/gh/zerodevx/zero-md@2/dist/zero-md.min.js'
    class ZeroMdCustom extends ZeroMD {
      constructor() {
        super()
      }
      async render(opts = {}) {
        await this.waitForReady()
        const styles = await this.stampStyles(this.buildStyles())
        await this.tick()
        const md = await this.buildMd(opts)
        // Apply MathJax parsing onto HTML string
        // ...
        const body = await this.stampBody(md, opts)
        this.fire('zero-md-rendered', { node: this, stamped: { styles, body } })
      }
    }
    customElements.define('zero-md', ZeroMdCustom)
  </script>
</head>
<body>
  <zero-md src="fixture.md"></zero-md>
</body>
RootofalleviI commented 1 year ago

Thanks!