Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/markdown-it/markdown-it-footnote
Footnotes plugin for markdown-it markdown parser
https://github.com/markdown-it/markdown-it-footnote
Last synced: 7 days ago
JSON representation
Footnotes plugin for markdown-it markdown parser
- Host: GitHub
- URL: https://github.com/markdown-it/markdown-it-footnote
- Owner: markdown-it
- License: mit
- Created: 2015-01-03T19:42:40.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2024-07-21T18:43:13.000Z (4 months ago)
- Last Synced: 2024-10-30T00:28:03.556Z (11 days ago)
- Language: JavaScript
- Homepage: https://markdown-it.github.io/
- Size: 46.9 KB
- Stars: 212
- Watchers: 11
- Forks: 59
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- keep-it-txt - markdown-it-footnote
README
# markdown-it-footnote
[![CI](https://github.com/markdown-it/markdown-it-footnote/actions/workflows/ci.yml/badge.svg)](https://github.com/markdown-it/markdown-it-footnote/actions/workflows/ci.yml)
[![NPM version](https://img.shields.io/npm/v/markdown-it-footnote.svg?style=flat)](https://www.npmjs.org/package/markdown-it-footnote)
[![Coverage Status](https://img.shields.io/coveralls/markdown-it/markdown-it-footnote/master.svg?style=flat)](https://coveralls.io/r/markdown-it/markdown-it-footnote?branch=master)> Footnotes plugin for [markdown-it](https://github.com/markdown-it/markdown-it) markdown parser.
__v2.+ requires `markdown-it` v5.+, see changelog.__
Markup is based on [pandoc](http://johnmacfarlane.net/pandoc/README.html#footnotes) definition.
__Normal footnote__:
```
Here is a footnote reference,[^1] and another.[^longnote][^1]: Here is the footnote.
[^longnote]: Here's one with multiple blocks.
Subsequent paragraphs are indented to show that they
belong to the previous footnote.
```html:
```html
Here is a footnote reference,[1] and another.[2]
This paragraph won’t be part of the note, because it
isn’t indented.
Here is the footnote. ↩
Here’s one with multiple blocks.
Subsequent paragraphs are indented to show that they
belong to the previous footnote. ↩```
__Inline footnote__:
```
Here is an inline note.^[Inlines notes are easier to write, since
you don't have to pick an identifier and move down to type the
note.]
```html:
```html
Here is an inline note.[1]
Inlines notes are easier to write, since
you don’t have to pick an identifier and move down to type the
note. ↩```
## Install
node.js, browser:
```bash
npm install markdown-it-footnote --save
bower install markdown-it-footnote --save
```## Use
```js
var md = require('markdown-it')()
.use(require('markdown-it-footnote'));md.render(/*...*/) // See examples above
```_Differences in browser._ If you load script directly into the page, without
package system, module will add itself globally as `window.markdownitFootnote`.### Customize
If you want to customize the output, you'll need to replace the template
functions. To see which templates exist and their default implementations,
look in [`index.js`](index.js). The API of these template functions is out of
scope for this plugin's documentation; you can read more about it [in the
markdown-it
documentation](https://github.com/markdown-it/markdown-it/blob/master/docs/architecture.md#renderer).To demonstrate with an example, here is how you might replace the `
` that
this plugin emits by default with an `` emitted by your own template
function override:```js
const md = require('markdown-it')().use(require('markdown-it-footnote'));md.renderer.rules.footnote_block_open = () => (
'Footnotes
\n' +
'\n' +
'\n'
);
```Here's another example that customizes footnotes for epub books:
```js
const backrefLabel = 'back to text';const epubRules = {
footnote_ref: [' {
let defaultRender = md.renderer.rules[rule];
md.renderer.rules[rule] = (tokens, idx, options, env, self) => {
return defaultRender(tokens, idx, options, env, self).replace(...epubRules[rule]);
}
})
```## License
[MIT](https://github.com/markdown-it/markdown-it-footnote/blob/master/LICENSE)