Skip to content

Commit d3dd4bc

Browse files
authored
feat: upgrade markdown-it types to v14 (#3772)
1 parent 74b725a commit d3dd4bc

File tree

7 files changed

+127
-70
lines changed

7 files changed

+127
-70
lines changed

Diff for: package.json

+12-8
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
"@docsearch/js": "^3.6.0",
107107
"@shikijs/core": "^1.2.4",
108108
"@shikijs/transformers": "^1.2.4",
109-
"@types/markdown-it": "^13.0.7",
109+
"@types/markdown-it": "^14.0.0",
110110
"@vitejs/plugin-vue": "^5.0.4",
111111
"@vue/devtools-api": "^7.0.25",
112112
"@vueuse/core": "^10.9.0",
@@ -120,13 +120,13 @@
120120
},
121121
"devDependencies": {
122122
"@clack/prompts": "^0.7.0",
123-
"@mdit-vue/plugin-component": "2.0.0",
124-
"@mdit-vue/plugin-frontmatter": "2.0.0",
125-
"@mdit-vue/plugin-headers": "2.0.0",
126-
"@mdit-vue/plugin-sfc": "2.0.0",
127-
"@mdit-vue/plugin-title": "2.0.0",
128-
"@mdit-vue/plugin-toc": "2.0.0",
129-
"@mdit-vue/shared": "2.0.0",
123+
"@mdit-vue/plugin-component": "^2.1.0",
124+
"@mdit-vue/plugin-frontmatter": "^2.1.0",
125+
"@mdit-vue/plugin-headers": "^2.1.0",
126+
"@mdit-vue/plugin-sfc": "^2.1.0",
127+
"@mdit-vue/plugin-title": "^2.1.0",
128+
"@mdit-vue/plugin-toc": "^2.1.0",
129+
"@mdit-vue/shared": "^2.1.0",
130130
"@polka/compression": "1.0.0-next.25",
131131
"@rollup/plugin-alias": "^5.1.0",
132132
"@rollup/plugin-commonjs": "^25.0.7",
@@ -221,6 +221,10 @@
221221
},
222222
"overrides": {
223223
"ora>string-width": "^5"
224+
},
225+
"patchedDependencies": {
226+
"@types/[email protected]": "patches/@[email protected]",
227+
224228
}
225229
}
226230
}

Diff for: patches/@[email protected]

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/package.json b/package.json
2+
index 46d7bfb79a36d8090d98d1ea1e36216137e00072..7bc1e8be5f1c5b74f52f7fa08935d2df3d19d3e2 100644
3+
--- a/package.json
4+
+++ b/package.json
5+
@@ -27,7 +27,7 @@
6+
}
7+
],
8+
"main": "",
9+
- "types": "index.d.ts",
10+
+ "types": "index.d.mts",
11+
"exports": {
12+
".": {
13+
"import": "./index.d.mts",

Diff for: patches/[email protected]

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
diff --git a/types/index.d.ts b/types/index.d.ts
2+
index 7c94aae194faa66ca006ace98cdb0dee82a3e471..0377cace7c4a9653d4ecf963babffd4bd68494b0 100644
3+
--- a/types/index.d.ts
4+
+++ b/types/index.d.ts
5+
@@ -1,10 +1,10 @@
6+
-import MarkdownIt = require('markdown-it');
7+
-import Token = require('markdown-it/lib/token');
8+
-import State = require('markdown-it/lib/rules_core/state_core');
9+
+import MarkdownIt from 'markdown-it';
10+
+import Token from 'markdown-it/lib/token.mjs';
11+
+import StateCore from 'markdown-it/lib/rules_core/state_core.mjs';
12+
13+
declare namespace anchor {
14+
- export type RenderHref = (slug: string, state: State) => string;
15+
- export type RenderAttrs = (slug: string, state: State) => Record<string, string | number>;
16+
+ export type RenderHref = (slug: string, state: StateCore) => string;
17+
+ export type RenderAttrs = (slug: string, state: StateCore) => Record<string, string | number>;
18+
19+
export interface PermalinkOptions {
20+
class?: string,
21+
@@ -37,7 +37,7 @@ declare namespace anchor {
22+
placement?: 'before' | 'after'
23+
}
24+
25+
- export type PermalinkGenerator = (slug: string, opts: PermalinkOptions, state: State, index: number) => void;
26+
+ export type PermalinkGenerator = (slug: string, opts: PermalinkOptions, state: StateCore, index: number) => void;
27+
28+
export interface AnchorInfo {
29+
slug: string;

Diff for: pnpm-lock.yaml

+66-56
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/node/markdown/markdown.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ import { titlePlugin } from '@mdit-vue/plugin-title'
1515
import { tocPlugin, type TocPluginOptions } from '@mdit-vue/plugin-toc'
1616
import { slugify } from '@mdit-vue/shared'
1717
import MarkdownIt from 'markdown-it'
18+
import type { Options } from 'markdown-it'
1819
import anchorPlugin from 'markdown-it-anchor'
1920
import attrsPlugin from 'markdown-it-attrs'
20-
// @ts-ignore
21+
// @ts-expect-error: types of markdown-it-emoji are not up-to-date
2122
import { full as emojiPlugin } from 'markdown-it-emoji'
2223
import type {
2324
BuiltinTheme,
@@ -47,7 +48,7 @@ export type ThemeOptions =
4748
dark: ThemeRegistrationAny | BuiltinTheme
4849
}
4950

50-
export interface MarkdownOptions extends MarkdownIt.Options {
51+
export interface MarkdownOptions extends Options {
5152
/* ==================== General Options ==================== */
5253

5354
/**

Diff for: src/node/markdown/plugins/containers.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type MarkdownIt from 'markdown-it'
2-
import type { RenderRule } from 'markdown-it/lib/renderer'
3-
import type Token from 'markdown-it/lib/token'
2+
import type { RenderRule } from 'markdown-it/lib/renderer.mjs'
3+
import type Token from 'markdown-it/lib/token.mjs'
44
import container from 'markdown-it-container'
55
import { nanoid } from 'nanoid'
66
import {

Diff for: src/node/markdown/plugins/snippet.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from 'fs-extra'
22
import type MarkdownIt from 'markdown-it'
3-
import type { RuleBlock } from 'markdown-it/lib/parser_block'
3+
import type ParserBlock from 'markdown-it/lib/parser_block.mjs'
44
import path from 'path'
55
import type { MarkdownEnv } from '../../shared'
66

@@ -98,7 +98,7 @@ function findRegion(lines: Array<string>, regionName: string) {
9898
}
9999

100100
export const snippetPlugin = (md: MarkdownIt, srcDir: string) => {
101-
const parser: RuleBlock = (state, startLine, endLine, silent) => {
101+
const parser: ParserBlock.RuleBlock = (state, startLine, endLine, silent) => {
102102
const CH = '<'.charCodeAt(0)
103103
const pos = state.bMarks[startLine] + state.tShift[startLine]
104104
const max = state.eMarks[startLine]

0 commit comments

Comments
 (0)