I am trying to use the markdown-it-footnote extension for the markdown-it JS parser.
The readme gives an example of how to install it when using node.js:
var md = require('markdown-it')()
.use(require('markdown-it-footnote'));
md.render(/*...*/) // See examples above
However I am not using node.js (and have never done so far). How can I embed the extension directly into the HTML-document?
I use the markdown-it-parser as follows:
<script type="text/javascript" src="https://cdn.jsdelivr.net/markdown-it/8.2.2/markdown-it.min.js"></script>
<script type="text/javascript">
var md = window.markdownit();
md.render(...);
</script>
The markdown-it-footnote-readme also states:
If you load script directly into the page, without package system, module will add itself globally as window.markdownitFootnote.
I tried to use it in many ways but was not successful:
var md = window.markdownit();
md = window.markdownitFootnote();
or
var md = window.markdownit().markdownitFootnote;
or
var md = window.markdownit(window.markdownitFootnote);
...
I just found the solution. Use:
<script type="text/javascript">
var md = window.markdownit().use(markdownitFootnote);
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With