Refactor routing in App component to enhance navigation and improve error handling by integrating dynamic routes and updating the NotFound route.
This commit is contained in:
34
node_modules/mdast-util-gfm-footnote/index.d.ts
generated
vendored
Normal file
34
node_modules/mdast-util-gfm-footnote/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
export {gfmFootnoteFromMarkdown, gfmFootnoteToMarkdown} from './lib/index.js'
|
||||
|
||||
export interface ToMarkdownOptions {
|
||||
// To do: next major: change default.
|
||||
/**
|
||||
* Use a blank line for the first line of footnote definitions
|
||||
* (`boolean`, default: `false`).
|
||||
*/
|
||||
firstLineBlank?: boolean | null | undefined
|
||||
}
|
||||
|
||||
declare module 'mdast-util-to-markdown' {
|
||||
interface ConstructNameMap {
|
||||
/**
|
||||
* Footnote definition.
|
||||
*
|
||||
* ```markdown
|
||||
* > | [^a]: B.
|
||||
* ^^^^^^^^
|
||||
* ```
|
||||
*/
|
||||
footnoteDefinition: 'footnoteDefinition'
|
||||
|
||||
/**
|
||||
* Footnote reference.
|
||||
*
|
||||
* ```markdown
|
||||
* > | A[^b].
|
||||
* ^^^^
|
||||
* ```
|
||||
*/
|
||||
footnoteReference: 'footnoteReference'
|
||||
}
|
||||
}
|
2
node_modules/mdast-util-gfm-footnote/index.js
generated
vendored
Normal file
2
node_modules/mdast-util-gfm-footnote/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// Note: extra types exported from `index.d.ts`.
|
||||
export {gfmFootnoteFromMarkdown, gfmFootnoteToMarkdown} from './lib/index.js'
|
22
node_modules/mdast-util-gfm-footnote/lib/index.d.ts
generated
vendored
Normal file
22
node_modules/mdast-util-gfm-footnote/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Create an extension for `mdast-util-from-markdown` to enable GFM footnotes
|
||||
* in markdown.
|
||||
*
|
||||
* @returns {FromMarkdownExtension}
|
||||
* Extension for `mdast-util-from-markdown`.
|
||||
*/
|
||||
export function gfmFootnoteFromMarkdown(): FromMarkdownExtension;
|
||||
/**
|
||||
* Create an extension for `mdast-util-to-markdown` to enable GFM footnotes
|
||||
* in markdown.
|
||||
*
|
||||
* @param {ToMarkdownOptions | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns {ToMarkdownExtension}
|
||||
* Extension for `mdast-util-to-markdown`.
|
||||
*/
|
||||
export function gfmFootnoteToMarkdown(options?: ToMarkdownOptions | null | undefined): ToMarkdownExtension;
|
||||
import type { Extension as FromMarkdownExtension } from 'mdast-util-from-markdown';
|
||||
import type { ToMarkdownOptions } from 'mdast-util-gfm-footnote';
|
||||
import type { Options as ToMarkdownExtension } from 'mdast-util-to-markdown';
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
node_modules/mdast-util-gfm-footnote/lib/index.d.ts.map
generated
vendored
Normal file
1
node_modules/mdast-util-gfm-footnote/lib/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AA0HA;;;;;;GAMG;AACH,2CAHa,qBAAqB,CAkBjC;AAED;;;;;;;;GAQG;AACH,gDALW,iBAAiB,GAAG,IAAI,GAAG,SAAS,GAElC,mBAAmB,CAiD/B;wDApMS,0BAA0B;uCACA,yBAAyB;oDAKnD,wBAAwB"}
|
212
node_modules/mdast-util-gfm-footnote/lib/index.js
generated
vendored
Normal file
212
node_modules/mdast-util-gfm-footnote/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
/**
|
||||
* @import {
|
||||
* CompileContext,
|
||||
* Extension as FromMarkdownExtension,
|
||||
* Handle as FromMarkdownHandle
|
||||
* } from 'mdast-util-from-markdown'
|
||||
* @import {ToMarkdownOptions} from 'mdast-util-gfm-footnote'
|
||||
* @import {
|
||||
* Handle as ToMarkdownHandle,
|
||||
* Map,
|
||||
* Options as ToMarkdownExtension
|
||||
* } from 'mdast-util-to-markdown'
|
||||
* @import {FootnoteDefinition, FootnoteReference} from 'mdast'
|
||||
*/
|
||||
|
||||
import {ok as assert} from 'devlop'
|
||||
import {normalizeIdentifier} from 'micromark-util-normalize-identifier'
|
||||
|
||||
footnoteReference.peek = footnoteReferencePeek
|
||||
|
||||
/**
|
||||
* @this {CompileContext}
|
||||
* @type {FromMarkdownHandle}
|
||||
*/
|
||||
function enterFootnoteCallString() {
|
||||
this.buffer()
|
||||
}
|
||||
|
||||
/**
|
||||
* @this {CompileContext}
|
||||
* @type {FromMarkdownHandle}
|
||||
*/
|
||||
function enterFootnoteCall(token) {
|
||||
this.enter({type: 'footnoteReference', identifier: '', label: ''}, token)
|
||||
}
|
||||
|
||||
/**
|
||||
* @this {CompileContext}
|
||||
* @type {FromMarkdownHandle}
|
||||
*/
|
||||
function enterFootnoteDefinitionLabelString() {
|
||||
this.buffer()
|
||||
}
|
||||
|
||||
/**
|
||||
* @this {CompileContext}
|
||||
* @type {FromMarkdownHandle}
|
||||
*/
|
||||
function enterFootnoteDefinition(token) {
|
||||
this.enter(
|
||||
{type: 'footnoteDefinition', identifier: '', label: '', children: []},
|
||||
token
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @this {CompileContext}
|
||||
* @type {FromMarkdownHandle}
|
||||
*/
|
||||
function exitFootnoteCallString(token) {
|
||||
const label = this.resume()
|
||||
const node = this.stack[this.stack.length - 1]
|
||||
assert(node.type === 'footnoteReference')
|
||||
node.identifier = normalizeIdentifier(
|
||||
this.sliceSerialize(token)
|
||||
).toLowerCase()
|
||||
node.label = label
|
||||
}
|
||||
|
||||
/**
|
||||
* @this {CompileContext}
|
||||
* @type {FromMarkdownHandle}
|
||||
*/
|
||||
function exitFootnoteCall(token) {
|
||||
this.exit(token)
|
||||
}
|
||||
|
||||
/**
|
||||
* @this {CompileContext}
|
||||
* @type {FromMarkdownHandle}
|
||||
*/
|
||||
function exitFootnoteDefinitionLabelString(token) {
|
||||
const label = this.resume()
|
||||
const node = this.stack[this.stack.length - 1]
|
||||
assert(node.type === 'footnoteDefinition')
|
||||
node.identifier = normalizeIdentifier(
|
||||
this.sliceSerialize(token)
|
||||
).toLowerCase()
|
||||
node.label = label
|
||||
}
|
||||
|
||||
/**
|
||||
* @this {CompileContext}
|
||||
* @type {FromMarkdownHandle}
|
||||
*/
|
||||
function exitFootnoteDefinition(token) {
|
||||
this.exit(token)
|
||||
}
|
||||
|
||||
/** @type {ToMarkdownHandle} */
|
||||
function footnoteReferencePeek() {
|
||||
return '['
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {ToMarkdownHandle}
|
||||
* @param {FootnoteReference} node
|
||||
*/
|
||||
function footnoteReference(node, _, state, info) {
|
||||
const tracker = state.createTracker(info)
|
||||
let value = tracker.move('[^')
|
||||
const exit = state.enter('footnoteReference')
|
||||
const subexit = state.enter('reference')
|
||||
value += tracker.move(
|
||||
state.safe(state.associationId(node), {after: ']', before: value})
|
||||
)
|
||||
subexit()
|
||||
exit()
|
||||
value += tracker.move(']')
|
||||
return value
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an extension for `mdast-util-from-markdown` to enable GFM footnotes
|
||||
* in markdown.
|
||||
*
|
||||
* @returns {FromMarkdownExtension}
|
||||
* Extension for `mdast-util-from-markdown`.
|
||||
*/
|
||||
export function gfmFootnoteFromMarkdown() {
|
||||
return {
|
||||
enter: {
|
||||
gfmFootnoteCallString: enterFootnoteCallString,
|
||||
gfmFootnoteCall: enterFootnoteCall,
|
||||
gfmFootnoteDefinitionLabelString: enterFootnoteDefinitionLabelString,
|
||||
gfmFootnoteDefinition: enterFootnoteDefinition
|
||||
},
|
||||
exit: {
|
||||
gfmFootnoteCallString: exitFootnoteCallString,
|
||||
gfmFootnoteCall: exitFootnoteCall,
|
||||
gfmFootnoteDefinitionLabelString: exitFootnoteDefinitionLabelString,
|
||||
gfmFootnoteDefinition: exitFootnoteDefinition
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an extension for `mdast-util-to-markdown` to enable GFM footnotes
|
||||
* in markdown.
|
||||
*
|
||||
* @param {ToMarkdownOptions | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns {ToMarkdownExtension}
|
||||
* Extension for `mdast-util-to-markdown`.
|
||||
*/
|
||||
export function gfmFootnoteToMarkdown(options) {
|
||||
// To do: next major: change default.
|
||||
let firstLineBlank = false
|
||||
|
||||
if (options && options.firstLineBlank) {
|
||||
firstLineBlank = true
|
||||
}
|
||||
|
||||
return {
|
||||
handlers: {footnoteDefinition, footnoteReference},
|
||||
// This is on by default already.
|
||||
unsafe: [{character: '[', inConstruct: ['label', 'phrasing', 'reference']}]
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {ToMarkdownHandle}
|
||||
* @param {FootnoteDefinition} node
|
||||
*/
|
||||
function footnoteDefinition(node, _, state, info) {
|
||||
const tracker = state.createTracker(info)
|
||||
let value = tracker.move('[^')
|
||||
const exit = state.enter('footnoteDefinition')
|
||||
const subexit = state.enter('label')
|
||||
value += tracker.move(
|
||||
state.safe(state.associationId(node), {before: value, after: ']'})
|
||||
)
|
||||
subexit()
|
||||
|
||||
value += tracker.move(']:')
|
||||
|
||||
if (node.children && node.children.length > 0) {
|
||||
tracker.shift(4)
|
||||
|
||||
value += tracker.move(
|
||||
(firstLineBlank ? '\n' : ' ') +
|
||||
state.indentLines(
|
||||
state.containerFlow(node, tracker.current()),
|
||||
firstLineBlank ? mapAll : mapExceptFirst
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
exit()
|
||||
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {Map} */
|
||||
function mapExceptFirst(line, index, blank) {
|
||||
return index === 0 ? line : mapAll(line, index, blank)
|
||||
}
|
||||
|
||||
/** @type {Map} */
|
||||
function mapAll(line, index, blank) {
|
||||
return (blank ? '' : ' ') + line
|
||||
}
|
22
node_modules/mdast-util-gfm-footnote/license
generated
vendored
Normal file
22
node_modules/mdast-util-gfm-footnote/license
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) Titus Wormer <tituswormer@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
111
node_modules/mdast-util-gfm-footnote/package.json
generated
vendored
Normal file
111
node_modules/mdast-util-gfm-footnote/package.json
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
{
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"bugs": "https://github.com/syntax-tree/mdast-util-gfm-footnote/issues",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
],
|
||||
"dependencies": {
|
||||
"@types/mdast": "^4.0.0",
|
||||
"devlop": "^1.1.0",
|
||||
"mdast-util-from-markdown": "^2.0.0",
|
||||
"mdast-util-to-markdown": "^2.0.0",
|
||||
"micromark-util-normalize-identifier": "^2.0.0"
|
||||
},
|
||||
"description": "mdast extension to parse and serialize GFM footnotes",
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.0.0",
|
||||
"c8": "^10.0.0",
|
||||
"micromark-extension-gfm-footnote": "^2.0.0",
|
||||
"prettier": "^3.0.0",
|
||||
"remark-cli": "^12.0.0",
|
||||
"remark-preset-wooorm": "^11.0.0",
|
||||
"type-coverage": "^2.0.0",
|
||||
"typescript": "^5.0.0",
|
||||
"xo": "^0.60.0"
|
||||
},
|
||||
"exports": "./index.js",
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"index.js",
|
||||
"lib/"
|
||||
],
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
},
|
||||
"keywords": [
|
||||
"footnote",
|
||||
"gfm",
|
||||
"markdown",
|
||||
"markup",
|
||||
"mdast-util",
|
||||
"mdast",
|
||||
"note",
|
||||
"unist",
|
||||
"utility",
|
||||
"util"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "mdast-util-gfm-footnote",
|
||||
"prettier": {
|
||||
"bracketSpacing": false,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "none",
|
||||
"useTabs": false
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"remark-preset-wooorm"
|
||||
]
|
||||
},
|
||||
"repository": "syntax-tree/mdast-util-gfm-footnote",
|
||||
"scripts": {
|
||||
"build": "tsc --build --clean && tsc --build && type-coverage",
|
||||
"format": "remark --frail --output --quiet -- . && prettier --log-level warn --write -- . && xo --fix",
|
||||
"test-api-dev": "node --conditions development test.js",
|
||||
"test-api-prod": "node --conditions production test.js",
|
||||
"test-api": "npm run test-api-dev && npm run test-api-prod",
|
||||
"test-coverage": "c8 --100 --reporter lcov npm run test-api",
|
||||
"test": "npm run build && npm run format && npm run test-coverage"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"typeCoverage": {
|
||||
"atLeast": 100,
|
||||
"strict": true
|
||||
},
|
||||
"type": "module",
|
||||
"version": "2.1.0",
|
||||
"xo": {
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"**/*.d.ts"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/array-type": [
|
||||
"error",
|
||||
{
|
||||
"default": "generic"
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/ban-types": [
|
||||
"error",
|
||||
{
|
||||
"extendDefaults": true
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/consistent-type-definitions": [
|
||||
"error",
|
||||
"interface"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"prettier": true,
|
||||
"rules": {
|
||||
"unicorn/prefer-at": "off"
|
||||
}
|
||||
}
|
||||
}
|
494
node_modules/mdast-util-gfm-footnote/readme.md
generated
vendored
Normal file
494
node_modules/mdast-util-gfm-footnote/readme.md
generated
vendored
Normal file
@@ -0,0 +1,494 @@
|
||||
# mdast-util-gfm-footnote
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
|
||||
[mdast][] extensions to parse and serialize [GFM][] footnotes.
|
||||
|
||||
## Contents
|
||||
|
||||
* [What is this?](#what-is-this)
|
||||
* [When to use this](#when-to-use-this)
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`gfmFootnoteFromMarkdown()`](#gfmfootnotefrommarkdown)
|
||||
* [`gfmFootnoteToMarkdown(options?)`](#gfmfootnotetomarkdownoptions)
|
||||
* [`ToMarkdownOptions`](#tomarkdownoptions)
|
||||
* [HTML](#html)
|
||||
* [Syntax](#syntax)
|
||||
* [Syntax tree](#syntax-tree)
|
||||
* [Nodes](#nodes)
|
||||
* [Content model](#content-model)
|
||||
* [Types](#types)
|
||||
* [Compatibility](#compatibility)
|
||||
* [Related](#related)
|
||||
* [Contribute](#contribute)
|
||||
* [License](#license)
|
||||
|
||||
## What is this?
|
||||
|
||||
This package contains two extensions that add support for GFM footnote syntax
|
||||
in markdown to [mdast][].
|
||||
These extensions plug into
|
||||
[`mdast-util-from-markdown`][mdast-util-from-markdown] (to support parsing
|
||||
footnotes in markdown into a syntax tree) and
|
||||
[`mdast-util-to-markdown`][mdast-util-to-markdown] (to support serializing
|
||||
footnotes in syntax trees to markdown).
|
||||
|
||||
GFM footnotes were [announced September 30, 2021][post] but are not specified.
|
||||
Their implementation on github.com is currently buggy.
|
||||
The bugs have been reported on [`cmark-gfm`][cmark-gfm].
|
||||
|
||||
## When to use this
|
||||
|
||||
You can use these extensions when you are working with
|
||||
`mdast-util-from-markdown` and `mdast-util-to-markdown` already.
|
||||
|
||||
When working with `mdast-util-from-markdown`, you must combine this package
|
||||
with [`micromark-extension-gfm-footnote`][micromark-extension-gfm-footnote].
|
||||
|
||||
When you don’t need a syntax tree, you can use [`micromark`][micromark]
|
||||
directly with `micromark-extension-gfm-footnote`.
|
||||
|
||||
When you are working with syntax trees and want all of GFM, use
|
||||
[`mdast-util-gfm`][mdast-util-gfm] instead.
|
||||
|
||||
All these packages are used [`remark-gfm`][remark-gfm], which
|
||||
focusses on making it easier to transform content by abstracting these
|
||||
internals away.
|
||||
|
||||
This utility does not handle how markdown is turned to HTML.
|
||||
That’s done by [`mdast-util-to-hast`][mdast-util-to-hast].
|
||||
If your content is not in English, you should configure that utility.
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 16+), install with [npm][]:
|
||||
|
||||
```sh
|
||||
npm install mdast-util-gfm-footnote
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
|
||||
```js
|
||||
import {gfmFootnoteFromMarkdown, gfmFootnoteToMarkdown} from 'https://esm.sh/mdast-util-gfm-footnote@2'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import {gfmFootnoteFromMarkdown, gfmFootnoteToMarkdown} from 'https://esm.sh/mdast-util-gfm-footnote@2?bundle'
|
||||
</script>
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
Say our document `example.md` contains:
|
||||
|
||||
```markdown
|
||||
In the Solar System, Mercury[^mercury] and Venus[^venus] have very small tilts.
|
||||
|
||||
[^mercury]:
|
||||
**Mercury** is the first planet from the Sun and the smallest
|
||||
in the Solar System.
|
||||
|
||||
[^venus]:
|
||||
**Venus** is the second planet from
|
||||
the Sun.
|
||||
```
|
||||
|
||||
…and our module `example.js` looks as follows:
|
||||
|
||||
```js
|
||||
import fs from 'node:fs/promises'
|
||||
import {fromMarkdown} from 'mdast-util-from-markdown'
|
||||
import {
|
||||
gfmFootnoteFromMarkdown,
|
||||
gfmFootnoteToMarkdown
|
||||
} from 'mdast-util-gfm-footnote'
|
||||
import {toMarkdown} from 'mdast-util-to-markdown'
|
||||
import {gfmFootnote} from 'micromark-extension-gfm-footnote'
|
||||
|
||||
const value = await fs.readFile('example.md', 'utf8')
|
||||
|
||||
const tree = fromMarkdown(value, {
|
||||
extensions: [gfmFootnote()],
|
||||
mdastExtensions: [gfmFootnoteFromMarkdown()]
|
||||
})
|
||||
|
||||
console.log(tree)
|
||||
|
||||
const result = toMarkdown(tree, {
|
||||
extensions: [gfmFootnoteToMarkdown({firstLineBlank: true})]
|
||||
})
|
||||
|
||||
console.log(result)
|
||||
```
|
||||
|
||||
…now running `node example.js` yields (positional info removed for brevity):
|
||||
|
||||
```js
|
||||
{
|
||||
type: 'root',
|
||||
children: [
|
||||
{
|
||||
type: 'paragraph',
|
||||
children: [
|
||||
{type: 'text', value: 'In the Solar System, Mercury'},
|
||||
{type: 'footnoteReference', identifier: 'mercury', label: 'mercury'},
|
||||
{type: 'text', value: ' and Venus'},
|
||||
{type: 'footnoteReference', identifier: 'venus', label: 'venus'},
|
||||
{type: 'text', value: ' have very small tilts.'}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'footnoteDefinition',
|
||||
identifier: 'mercury',
|
||||
label: 'mercury',
|
||||
children: [
|
||||
{
|
||||
type: 'paragraph',
|
||||
children: [
|
||||
{type: 'strong', children: [{type: 'text', value: 'Mercury'}]},
|
||||
{
|
||||
type: 'text',
|
||||
value:
|
||||
' is the first planet from the Sun and the smallest\n' +
|
||||
'in the Solar System.'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'footnoteDefinition',
|
||||
identifier: 'venus',
|
||||
label: 'venus',
|
||||
children: [
|
||||
{
|
||||
type: 'paragraph',
|
||||
children: [
|
||||
{type: 'strong', children: [{type: 'text', value: 'Venus'}]},
|
||||
{type: 'text', value: ' is the second planet from\nthe Sun.'}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
```markdown
|
||||
In the Solar System, Mercury[^mercury] and Venus[^venus] have very small tilts.
|
||||
|
||||
[^mercury]:
|
||||
**Mercury** is the first planet from the Sun and the smallest
|
||||
in the Solar System.
|
||||
|
||||
[^venus]:
|
||||
**Venus** is the second planet from
|
||||
the Sun.
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
This package exports the identifiers
|
||||
[`gfmFootnoteFromMarkdown`][api-gfmfootnotefrommarkdown] and
|
||||
[`gfmFootnoteToMarkdown`][api-gfmfootnotetomarkdown].
|
||||
There is no default export.
|
||||
It exports the type [`ToMarkdownOptions`][api-to-markdown-options].
|
||||
|
||||
### `gfmFootnoteFromMarkdown()`
|
||||
|
||||
Create an extension for
|
||||
[`mdast-util-from-markdown`][mdast-util-from-markdown]
|
||||
to enable GFM footnotes in markdown.
|
||||
|
||||
###### Returns
|
||||
|
||||
Extension for `mdast-util-from-markdown`
|
||||
([`FromMarkdownExtension`][frommarkdownextension]).
|
||||
|
||||
### `gfmFootnoteToMarkdown(options?)`
|
||||
|
||||
Create an extension for
|
||||
[`mdast-util-to-markdown`][mdast-util-to-markdown]
|
||||
to enable GFM footnotes in markdown.
|
||||
|
||||
###### Parameters
|
||||
|
||||
* `options` ([`ToMarkdownOptions`][api-to-markdown-options], optional)
|
||||
— configuration
|
||||
|
||||
###### Returns
|
||||
|
||||
Extension for `mdast-util-to-markdown`
|
||||
([`ToMarkdownExtension`][tomarkdownextension]).
|
||||
|
||||
### `ToMarkdownOptions`
|
||||
|
||||
Configuration (TypeScript type).
|
||||
|
||||
###### Fields
|
||||
|
||||
* `firstLineBlank` (`boolean`, default: `false`)
|
||||
— use a blank line for the first line of footnote definitions
|
||||
|
||||
## HTML
|
||||
|
||||
This utility does not handle how markdown is turned to HTML.
|
||||
That’s done by [`mdast-util-to-hast`][mdast-util-to-hast].
|
||||
If your content is not in English, you should configure that utility.
|
||||
|
||||
## Syntax
|
||||
|
||||
See [Syntax in `micromark-extension-gfm-footnote`][syntax].
|
||||
|
||||
## Syntax tree
|
||||
|
||||
The following interfaces are added to **[mdast][]** by this utility.
|
||||
|
||||
### Nodes
|
||||
|
||||
#### `FootnoteDefinition`
|
||||
|
||||
```idl
|
||||
interface FootnoteDefinition <: Parent {
|
||||
type: 'footnoteDefinition'
|
||||
children: [FlowContent]
|
||||
}
|
||||
|
||||
FootnoteDefinition includes Association
|
||||
```
|
||||
|
||||
**FootnoteDefinition** (**[Parent][dfn-parent]**) represents content relating
|
||||
to the document that is outside its flow.
|
||||
|
||||
**FootnoteDefinition** can be used where **[flow][dfn-flow-content]** content
|
||||
is expected.
|
||||
Its content model is also **[flow][dfn-flow-content]** content.
|
||||
|
||||
**FootnoteDefinition** includes the mixin
|
||||
**[Association][dfn-mxn-association]**.
|
||||
|
||||
**FootnoteDefinition** should be associated with
|
||||
**[FootnoteReferences][dfn-footnote-reference]**.
|
||||
|
||||
For example, the following markdown:
|
||||
|
||||
```markdown
|
||||
[^alpha]: bravo and charlie.
|
||||
```
|
||||
|
||||
Yields:
|
||||
|
||||
```js
|
||||
{
|
||||
type: 'footnoteDefinition',
|
||||
identifier: 'alpha',
|
||||
label: 'alpha',
|
||||
children: [{
|
||||
type: 'paragraph',
|
||||
children: [{type: 'text', value: 'bravo and charlie.'}]
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
#### `FootnoteReference`
|
||||
|
||||
```idl
|
||||
interface FootnoteReference <: Node {
|
||||
type: 'footnoteReference'
|
||||
}
|
||||
|
||||
FootnoteReference includes Association
|
||||
```
|
||||
|
||||
**FootnoteReference** (**[Node][dfn-node]**) represents a marker through
|
||||
association.
|
||||
|
||||
**FootnoteReference** can be used where
|
||||
**[phrasing][dfn-phrasing-content]** content is expected.
|
||||
It has no content model.
|
||||
|
||||
**FootnoteReference** includes the mixin **[Association][dfn-mxn-association]**.
|
||||
|
||||
**FootnoteReference** should be associated with a
|
||||
**[FootnoteDefinition][dfn-footnote-definition]**.
|
||||
|
||||
For example, the following markdown:
|
||||
|
||||
```markdown
|
||||
[^alpha]
|
||||
```
|
||||
|
||||
Yields:
|
||||
|
||||
```js
|
||||
{
|
||||
type: 'footnoteReference',
|
||||
identifier: 'alpha',
|
||||
label: 'alpha'
|
||||
}
|
||||
```
|
||||
|
||||
### Content model
|
||||
|
||||
#### `FlowContent` (GFM footnotes)
|
||||
|
||||
```idl
|
||||
type FlowContentGfm = FootnoteDefinition | FlowContent
|
||||
```
|
||||
|
||||
#### `PhrasingContent` (GFM footnotes)
|
||||
|
||||
```idl
|
||||
type PhrasingContentGfm = FootnoteReference | PhrasingContent
|
||||
```
|
||||
|
||||
## Types
|
||||
|
||||
This package is fully typed with [TypeScript][].
|
||||
It does not export additional types.
|
||||
|
||||
The `FootnoteDefinition` and `FootnoteReference` types of the mdast nodes are
|
||||
exposed from `@types/mdast`.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
|
||||
When we cut a new major release, we drop support for unmaintained versions of
|
||||
Node.
|
||||
This means we try to keep the current release line,
|
||||
`mdast-util-gfm-footnote@^2`, compatible with Node.js 16.
|
||||
|
||||
## Related
|
||||
|
||||
* [`remark-gfm`][remark-gfm]
|
||||
— remark plugin to support GFM
|
||||
* [`mdast-util-gfm`][mdast-util-gfm]
|
||||
— same but all of GFM (autolink literals, footnotes, strikethrough, tables,
|
||||
tasklists)
|
||||
* [`micromark-extension-gfm-footnote`][micromark-extension-gfm-footnote]
|
||||
— micromark extension to parse GFM footnotes
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
|
||||
ways to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
|
||||
<!-- Definitions -->
|
||||
|
||||
[api-gfmfootnotefrommarkdown]: #gfmfootnotefrommarkdown
|
||||
|
||||
[api-gfmfootnotetomarkdown]: #gfmfootnotetomarkdownoptions
|
||||
|
||||
[api-to-markdown-options]: #tomarkdownoptions
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[build]: https://github.com/syntax-tree/mdast-util-gfm-footnote/actions
|
||||
|
||||
[build-badge]: https://github.com/syntax-tree/mdast-util-gfm-footnote/workflows/main/badge.svg
|
||||
|
||||
[chat]: https://github.com/syntax-tree/unist/discussions
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[cmark-gfm]: https://github.com/github/cmark-gfm
|
||||
|
||||
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
|
||||
|
||||
[coverage]: https://codecov.io/github/syntax-tree/mdast-util-gfm-footnote
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-gfm-footnote.svg
|
||||
|
||||
[dfn-flow-content]: #flowcontent-gfm-footnotes
|
||||
|
||||
[dfn-footnote-definition]: #footnotedefinition
|
||||
|
||||
[dfn-footnote-reference]: #footnotereference
|
||||
|
||||
[dfn-mxn-association]: https://github.com/syntax-tree/mdast#association
|
||||
|
||||
[dfn-node]: https://github.com/syntax-tree/unist#node
|
||||
|
||||
[dfn-parent]: https://github.com/syntax-tree/mdast#parent
|
||||
|
||||
[dfn-phrasing-content]: #phrasingcontent-gfm-footnotes
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/mdast-util-gfm-footnote
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/mdast-util-gfm-footnote.svg
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[frommarkdownextension]: https://github.com/syntax-tree/mdast-util-from-markdown#extension
|
||||
|
||||
[gfm]: https://github.github.com/gfm/
|
||||
|
||||
[health]: https://github.com/syntax-tree/.github
|
||||
|
||||
[license]: license
|
||||
|
||||
[mdast]: https://github.com/syntax-tree/mdast
|
||||
|
||||
[mdast-util-from-markdown]: https://github.com/syntax-tree/mdast-util-from-markdown
|
||||
|
||||
[mdast-util-gfm]: https://github.com/syntax-tree/mdast-util-gfm
|
||||
|
||||
[mdast-util-to-hast]: https://github.com/syntax-tree/mdast-util-to-hast
|
||||
|
||||
[mdast-util-to-markdown]: https://github.com/syntax-tree/mdast-util-to-markdown
|
||||
|
||||
[micromark]: https://github.com/micromark/micromark
|
||||
|
||||
[micromark-extension-gfm-footnote]: https://github.com/micromark/micromark-extension-gfm-footnote
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[post]: https://github.blog/changelog/2021-09-30-footnotes-now-supported-in-markdown-fields/
|
||||
|
||||
[remark-gfm]: https://github.com/remarkjs/remark-gfm
|
||||
|
||||
[size]: https://bundlejs.com/?q=mdast-util-gfm-footnote
|
||||
|
||||
[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=mdast-util-gfm-footnote
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
|
||||
|
||||
[syntax]: https://github.com/micromark/micromark-extension-gfm-footnote#syntax
|
||||
|
||||
[tomarkdownextension]: https://github.com/syntax-tree/mdast-util-to-markdown#options
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
Reference in New Issue
Block a user