This repository has been archived by the owner on Oct 1, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
96 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.DS_Store | ||
*.log | ||
coverage/ | ||
node_modules/ | ||
.DS_Store | ||
*.d.ts | ||
*.log | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,38 @@ | ||
/** | ||
* @typedef {import('mdast').Root} Root | ||
* | ||
* @typedef Options | ||
* Configuration. | ||
* @property {boolean} [inlineNotes=false] | ||
* Whether to support `^[inline notes]`. | ||
*/ | ||
|
||
import {footnote} from 'micromark-extension-footnote' | ||
import {footnoteFromMarkdown, footnoteToMarkdown} from 'mdast-util-footnote' | ||
|
||
export default function remarkFootnotes(options) { | ||
/** | ||
* Plugin to add support for footnotes. | ||
* | ||
* @type {import('unified').Plugin<[Options?]|void[], Root>} | ||
*/ | ||
export default function remarkFootnotes(options = {}) { | ||
const data = this.data() | ||
|
||
add('micromarkExtensions', footnote(options)) | ||
add('fromMarkdownExtensions', footnoteFromMarkdown) | ||
add('toMarkdownExtensions', footnoteToMarkdown) | ||
|
||
/** | ||
* @param {string} field | ||
* @param {unknown} value | ||
*/ | ||
function add(field, value) { | ||
// Other extensions. | ||
/* c8 ignore next */ | ||
if (data[field]) data[field].push(value) | ||
else data[field] = [value] | ||
const list = /** @type {unknown[]} */ ( | ||
// Other extensions | ||
/* c8 ignore next 2 */ | ||
data[field] ? data[field] : (data[field] = []) | ||
) | ||
|
||
list.push(value) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"include": ["test/**/*.js", "*.js"], | ||
"compilerOptions": { | ||
"target": "ES2020", | ||
"lib": ["ES2020"], | ||
"module": "ES2020", | ||
"moduleResolution": "node", | ||
"allowJs": true, | ||
"checkJs": true, | ||
"declaration": true, | ||
"emitDeclarationOnly": true, | ||
"allowSyntheticDefaultImports": true, | ||
"skipLibCheck": true, | ||
"strict": true | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.