mathpix-markdown-it icon indicating copy to clipboard operation
mathpix-markdown-it copied to clipboard

Not working with remix.run

Open JakovGlavac opened this issue 3 years ago • 1 comments

Hi, I'm trying to use mathpix-markdown-it with remix.run framework, but I get error: image. I "solved" it by just commenting out lines with errors, but then I get another error: image I "solved" this one by adding this line to root.tsx: image But then again I got another error: image.

I don't know what to do anymore.

Here is reproduceable: https://codesandbox.io/s/relaxed-torvalds-mknke?file=/app/routes/index.jsx

JakovGlavac avatar Feb 15 '22 00:02 JakovGlavac

Hey, @JakovGlavac I need to figure out why this isn't working for remix.run. Maybe it's because you are using strict mode.

But you can use the approach described here https://github.com/Mathpix/mathpix-markdown-it/issues/95#issuecomment-760991632

Add it into Document function

        <script src={'https://cdn.jsdelivr.net/npm/[email protected]/es5/bundle.js'}/>
        <div dangerouslySetInnerHTML={ {
          __html: '<script>const global = window; const isLoaded = window.loadMathJax(); if (isLoaded) console.log(\'Styles loaded!\')</script>'
        } }/>

Then you can use it in your component :

          <div dangerouslySetInnerHTML={ {__html: window.markdownToHTML("\\(ax^2 + bx + c = 0\\)")}}/>
          <div dangerouslySetInnerHTML={ {__html: window.markdownToHTML("$x = \\frac { - b \\pm \\sqrt { b ^ { 2 } - 4 a c } } { 2 a }$")}}/>

Result

Screen Shot 2022-02-15 at 11 51 02

OlgaRedozubova avatar Feb 15 '22 09:02 OlgaRedozubova