Adding mathjax—or any client-side library #79
Unanswered
amingilani
asked this question in
Support
Replies: 1 comment 4 replies
-
Hi @amingilani, good to hear that you like Doks! There are a number of ways to do this . A quick way would be:
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
Content-Security-Policy: default-src 'self'; manifest-src 'self'; connect-src 'self'; font-src 'self' https://cdn.jsdelivr.net/; img-src 'self' data:; script-src 'self' https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js https://polyfill.io/v3/polyfill.min.js; style-src 'self' 'unsafe-inline' Then, when you add e.g. the following to a markdown content file: <p>
When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c = 0\) and they are \[x = {-b \pm \sqrt{b^2-4ac} \over 2a}.\]
</p> This will be converted as follows: P.S. (1) Note the added P.S. (2) I'm planning to write a guide on adding KaTeX — will be available soon. And, a more general guide like you hinted. Both guides will use npm for adding the scripts (for better dependency management and improved security reasons mainly). Hope this helps! |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, and first of all, thank you so much for creating this—it was perfect and got me up and running quickly!
I apologize, but I'm new to both Doks and Hugo all at once. That said, what would be the quickest way of installing MathJax in my docs?
Things I've tried:
<script type="text/javascript" id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
will fail in production<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" integrity="sha384-fNl9rj/eK1wEYfKc26CbPM6qkVQ+9MvYaoAFNql4ulbjBEWV2XLNP1UB8jQTtSe3" crossorigin="anonymous"></script>
I'm assuming this would apply to any client-side library like D3.js or Chart.js.
Beta Was this translation helpful? Give feedback.
All reactions