├── .gitignore ├── test ├── cjs.js ├── fixtures │ ├── footnote-prefixed.txt │ └── footnote.txt └── test.mjs ├── .github ├── dependabot.yml └── workflows │ └── ci.yml ├── .eslintrc.yml ├── CHANGELOG.md ├── LICENSE ├── package.json ├── rollup.config.mjs ├── README.md └── index.mjs /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | coverage/ 3 | dist/ 4 | -------------------------------------------------------------------------------- /test/cjs.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | /* eslint-env mocha */ 3 | 4 | const assert = require('node:assert') 5 | const fn = require('../') 6 | 7 | describe('CJS', () => { 8 | it('require', () => { 9 | assert.ok(typeof fn === 'function') 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: / 5 | schedule: 6 | interval: daily 7 | 8 | - package-ecosystem: npm 9 | directory: / 10 | schedule: 11 | interval: daily 12 | allow: 13 | - dependency-type: production 14 | -------------------------------------------------------------------------------- /.eslintrc.yml: -------------------------------------------------------------------------------- 1 | extends: standard 2 | 3 | overrides: 4 | - 5 | files: [ '*.mjs' ] 6 | rules: 7 | no-restricted-globals: [ 2, require, __dirname ] 8 | - 9 | files: [ 'test/**' ] 10 | env: { mocha: true } 11 | - 12 | files: [ 'lib/**', 'index.mjs' ] 13 | parserOptions: { ecmaVersion: 2015 } 14 | 15 | ignorePatterns: 16 | - demo/ 17 | - dist/ 18 | - benchmark/extra/ 19 | 20 | rules: 21 | camelcase: 0 22 | no-multi-spaces: 0 23 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | pull_request: 6 | schedule: 7 | - cron: '0 0 * * 3' 8 | 9 | jobs: 10 | test: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | strategy: 15 | matrix: 16 | node-version: [ '18' ] 17 | 18 | steps: 19 | - uses: actions/checkout@v4 20 | 21 | - name: Use Node.js ${{ matrix.node-version }} 22 | uses: actions/setup-node@v4 23 | with: 24 | node-version: ${{ matrix.node-version }} 25 | 26 | - run: npm install 27 | 28 | - name: Test 29 | run: npm test 30 | 31 | - name: Upload coverage report to coveralls.io 32 | uses: coverallsapp/github-action@master 33 | with: 34 | github-token: ${{ secrets.GITHUB_TOKEN }} 35 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 4.0.0 / 2023-12-06 2 | ------------------ 3 | 4 | - Rewrite to ESM. 5 | - Remove `dist/` from repo (build on package publish). 6 | 7 | 8 | 3.0.3 / 2021-05-20 9 | ------------------ 10 | 11 | - Fix crash on nested footnotes, #42. 12 | 13 | 14 | 3.0.2 / 2019-07-09 15 | ------------------ 16 | 17 | - Fix URLs in inline footnotes, #33. 18 | 19 | 20 | 3.0.1 / 2016-08-05 21 | ------------------ 22 | 23 | - Fix anchor links in duplicate footnotes, #13. 24 | 25 | 26 | 3.0.0 / 2016-06-28 27 | ------------------ 28 | 29 | - Add `env.docId` support to guarantee unique ancors for differenet docements. 30 | - Add overridable helpers: `md.renderer.rules.footnote_anchor_name` 31 | & `md.renderer.rules.footnote_caption` to simplify templating. 32 | - Fixed anchor symbol display on iOS, #11. 33 | 34 | 35 | 2.0.0 / 2015-10-05 36 | ------------------ 37 | 38 | - Markdown-it 5.0.0 support. Use 1.x version for 4.x. 39 | 40 | 41 | 1.0.0 / 2015-03-12 42 | ------------------ 43 | 44 | - Markdown-it 4.0.0 support. Use previous version for 2.x-3.x. 45 | 46 | 47 | 0.1.0 / 2015-01-04 48 | ------------------ 49 | 50 | - First release. 51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-2015 Vitaly Puzrin, Alex Kocharin. 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "markdown-it-footnote", 3 | "version": "4.0.0", 4 | "description": "Footnotes for markdown-it markdown parser.", 5 | "keywords": [ 6 | "markdown-it-plugin", 7 | "markdown-it", 8 | "markdown", 9 | "footnotes" 10 | ], 11 | "repository": "markdown-it/markdown-it-footnote", 12 | "license": "MIT", 13 | "main": "dist/index.cjs.js", 14 | "module": "index.mjs", 15 | "exports": { 16 | ".": { 17 | "require": "./dist/index.cjs.js", 18 | "import": "./index.mjs" 19 | }, 20 | "./*": { 21 | "require": "./*", 22 | "import": "./*" 23 | } 24 | }, 25 | "files": [ 26 | "index.mjs", 27 | "lib/", 28 | "dist/" 29 | ], 30 | "scripts": { 31 | "lint": "eslint .", 32 | "build": "rollup -c", 33 | "test": "npm run lint && npm run build && c8 --exclude dist --exclude test -r text -r html -r lcov mocha", 34 | "prepublishOnly": "npm run lint && npm run build" 35 | }, 36 | "devDependencies": { 37 | "@rollup/plugin-babel": "^6.0.4", 38 | "@rollup/plugin-node-resolve": "^15.2.3", 39 | "@rollup/plugin-terser": "^0.4.4", 40 | "c8": "^8.0.1", 41 | "eslint": "^8.55.0", 42 | "eslint-config-standard": "^17.1.0", 43 | "markdown-it": "^13.0.2", 44 | "markdown-it-testgen": "^0.1.6", 45 | "mocha": "^10.2.0", 46 | "rollup": "^4.6.1" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /test/fixtures/footnote-prefixed.txt: -------------------------------------------------------------------------------- 1 | . 2 | Here is a footnote reference,[^1] and another.[^longnote] 3 | 4 | [^1]: Here is the footnote. 5 | 6 | [^longnote]: Here's one with multiple blocks. 7 | 8 | Subsequent paragraphs are indented to show that they 9 | belong to the previous footnote. 10 | 11 | { some.code } 12 | 13 | The whole paragraph can be indented, or just the first 14 | line. In this way, multi-paragraph footnotes work like 15 | multi-paragraph list items. 16 | 17 | This paragraph won't be part of the note, because it 18 | isn't indented. 19 | . 20 |
Here is a footnote reference,[1] and another.[2]
21 |This paragraph won't be part of the note, because it 22 | isn't indented.
23 |Here is the footnote. ↩
27 |Here's one with multiple blocks.
29 |Subsequent paragraphs are indented to show that they 30 | belong to the previous footnote.
31 |{ some.code }
32 |
33 | The whole paragraph can be indented, or just the first 34 | line. In this way, multi-paragraph footnotes work like 35 | multi-paragraph list items. ↩
36 |Here is a footnote reference,[1] and another.[2]
30 |This paragraph won’t be part of the note, because it 31 | isn’t indented.
32 |Here is an inline note.[1]
57 |Inlines notes are easier to write, since 61 | you don’t have to pick an identifier and move down to type the 62 | note. ↩
63 |Here is a footnote reference,[1] and another.[2]
23 |This paragraph won't be part of the note, because it 24 | isn't indented.
25 |Here is the footnote. ↩
29 |Here's one with multiple blocks.
31 |Subsequent paragraphs are indented to show that they 32 | belong to the previous footnote.
33 |{ some.code }
34 |
35 | The whole paragraph can be indented, or just the first 36 | line. In this way, multi-paragraph footnotes work like 37 | multi-paragraph list items. ↩
38 |bar 82 | baz ↩
83 |[^ foo]: bar baz
98 |[^foo 99 | ]: bar baz
100 | . 101 | 102 | 103 | We support inline notes too (pandoc example): 104 | 105 | . 106 | Here is an inline note.^[Inlines notes are easier to write, since 107 | you don't have to pick an identifier and move down to type the 108 | note.] 109 | . 110 |Here is an inline note.[1]
111 |Inlines notes are easier to write, since 115 | you don't have to pick an identifier and move down to type the 116 | note. ↩
117 |foo[1]
129 |bar ↩
133 |foo ↩
214 |blah ↩
231 |blah ↩
248 |Example[1]
259 |this is another example https://github.com ↩︎
263 |