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=".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 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/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);
...
Share Improve this question edited Jan 8, 2017 at 22:50 Waylan 42.9k14 gold badges91 silver badges117 bronze badges asked Jan 6, 2017 at 8:27 PhilPhil 1511 silver badge6 bronze badges 1-
as the message states you should be able to access it like this:
window.markdownitFootnote
– Joel Harkes Commented Jan 6, 2017 at 8:39
1 Answer
Reset to default 8I just found the solution. Use:
<script type="text/javascript">
var md = window.markdownit().use(markdownitFootnote);
</script>