feat(markdown): support footnotes

pull/5339/head
Divyansh Singh 2 months ago
parent dabc5e95ce
commit 430a890a17

@ -115,6 +115,22 @@ For more details, see [Frontmatter](../reference/frontmatter-config).
- [ ] Write the press release - [ ] Write the press release
- [x] Update the website - [x] Update the website
## Footnotes
**Input**
```md
Footnotes are supported[^1], including inline ones^[This is an inline footnote.].
[^1]: Definitions can contain **markdown** and are rendered at the end of the page.
```
**Output**
Footnotes are supported[^1], including inline ones^[This is an inline footnote.].
[^1]: Definitions can contain **markdown** and are rendered at the end of the page.
## Emoji :tada: ## Emoji :tada:
**Input** **Input**

@ -131,6 +131,7 @@
"@mdit/plugin-attrs": "^1.0.2", "@mdit/plugin-attrs": "^1.0.2",
"@mdit/plugin-container": "^1.0.1", "@mdit/plugin-container": "^1.0.1",
"@mdit/plugin-emoji": "^1.1.0", "@mdit/plugin-emoji": "^1.1.0",
"@mdit/plugin-footnote": "^1.0.1",
"@mdit/plugin-tasklist": "^1.0.1", "@mdit/plugin-tasklist": "^1.0.1",
"@polka/compression": "^1.0.0-next.28", "@polka/compression": "^1.0.0-next.28",
"@rolldown/pluginutils": "^1.0.1", "@rolldown/pluginutils": "^1.0.1",

@ -105,6 +105,9 @@ importers:
'@mdit/plugin-emoji': '@mdit/plugin-emoji':
specifier: ^1.1.0 specifier: ^1.1.0
version: 1.1.0(markdown-it@14.3.0) version: 1.1.0(markdown-it@14.3.0)
'@mdit/plugin-footnote':
specifier: ^1.0.1
version: 1.0.1(markdown-it@14.3.0)
'@mdit/plugin-tasklist': '@mdit/plugin-tasklist':
specifier: ^1.0.1 specifier: ^1.0.1
version: 1.0.1(markdown-it@14.3.0) version: 1.0.1(markdown-it@14.3.0)
@ -665,6 +668,12 @@ packages:
markdown-it: markdown-it:
optional: true optional: true
'@mdit/plugin-footnote@1.0.1':
resolution: {integrity: sha512-PrH02dlVQT8/vPvfGrLHpcHq8N0+gOaAVNOfuhwlPqWCL4He3o+buUCxm1Uem02+UR8/TRBW50M/XD/dVSe2jw==}
engines: {node: '>=22'}
peerDependencies:
markdown-it: ^14.2.0
'@mdit/plugin-tasklist@1.0.1': '@mdit/plugin-tasklist@1.0.1':
resolution: {integrity: sha512-Ks/Tihw5ibbkP2qOZzltkbiTk8RfpxDRvqdn4hl1wIs3VmeKITIQ36gN4DsuotSauA9SBe/mL0QJIfuSCrXqrw==} resolution: {integrity: sha512-Ks/Tihw5ibbkP2qOZzltkbiTk8RfpxDRvqdn4hl1wIs3VmeKITIQ36gN4DsuotSauA9SBe/mL0QJIfuSCrXqrw==}
engines: {node: '>=22'} engines: {node: '>=22'}
@ -3117,6 +3126,11 @@ snapshots:
optionalDependencies: optionalDependencies:
markdown-it: 14.3.0 markdown-it: 14.3.0
'@mdit/plugin-footnote@1.0.1(markdown-it@14.3.0)':
dependencies:
'@types/markdown-it': 14.1.2
markdown-it: 14.3.0
'@mdit/plugin-tasklist@1.0.1(markdown-it@14.3.0)': '@mdit/plugin-tasklist@1.0.1(markdown-it@14.3.0)':
dependencies: dependencies:
'@types/markdown-it': 14.1.2 '@types/markdown-it': 14.1.2

@ -197,6 +197,19 @@
accent-color: var(--vp-c-brand-1); accent-color: var(--vp-c-brand-1);
} }
/**
* Footnotes
* -------------------------------------------------------------------------- */
.vp-doc .footnote-ref a,
.vp-doc .footnote-backref {
text-decoration: none;
}
.vp-doc .footnotes {
font-size: 14px;
}
/** /**
* Table * Table
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */

@ -20,6 +20,7 @@ import {
type MarkdownItAttrsOptions type MarkdownItAttrsOptions
} from '@mdit/plugin-attrs' } from '@mdit/plugin-attrs'
import { fullEmoji as emojiPlugin } from '@mdit/plugin-emoji' import { fullEmoji as emojiPlugin } from '@mdit/plugin-emoji'
import { footnote as footnotePlugin } from '@mdit/plugin-footnote'
import { import {
tasklist as tasklistPlugin, tasklist as tasklistPlugin,
type MarkdownItTaskListOptions type MarkdownItTaskListOptions
@ -227,6 +228,13 @@ export interface MarkdownOptions extends MarkdownItAsyncOptions {
* @see https://mdit-plugins.github.io/tasklist.html * @see https://mdit-plugins.github.io/tasklist.html
*/ */
tasklist?: MarkdownItTaskListOptions | boolean tasklist?: MarkdownItTaskListOptions | boolean
/**
* Whether to enable footnotes (`[^1]` references with definitions, plus
* inline `^[note]` syntax).
* @default true
* @see https://mdit-plugins.github.io/footnote.html
*/
footnote?: boolean
/** /**
* Improves emphasis (`**bold**`) handling in Japanese, Chinese, and * Improves emphasis (`**bold**`) handling in Japanese, Chinese, and
* Korean text. * Korean text.
@ -426,6 +434,9 @@ export async function createMarkdownRenderer(
if (options.tasklist !== false) { if (options.tasklist !== false) {
tasklistPlugin(md, normalizePluginOptions(options.tasklist)) tasklistPlugin(md, normalizePluginOptions(options.tasklist))
} }
if (options.footnote !== false) {
footnotePlugin(md)
}
if (options.cjkFriendlyEmphasis !== false) { if (options.cjkFriendlyEmphasis !== false) {
mditCjkFriendly(md) mditCjkFriendly(md)
} }

Loading…
Cancel
Save