feat: upgrade markdown-it types to v14 (#3772)

pull/3802/head
Xinyu Liu 3 months ago committed by GitHub
parent 74b725a224
commit d3dd4bc938
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -106,7 +106,7 @@
"@docsearch/js": "^3.6.0",
"@shikijs/core": "^1.2.4",
"@shikijs/transformers": "^1.2.4",
"@types/markdown-it": "^13.0.7",
"@types/markdown-it": "^14.0.0",
"@vitejs/plugin-vue": "^5.0.4",
"@vue/devtools-api": "^7.0.25",
"@vueuse/core": "^10.9.0",
@ -120,13 +120,13 @@
},
"devDependencies": {
"@clack/prompts": "^0.7.0",
"@mdit-vue/plugin-component": "2.0.0",
"@mdit-vue/plugin-frontmatter": "2.0.0",
"@mdit-vue/plugin-headers": "2.0.0",
"@mdit-vue/plugin-sfc": "2.0.0",
"@mdit-vue/plugin-title": "2.0.0",
"@mdit-vue/plugin-toc": "2.0.0",
"@mdit-vue/shared": "2.0.0",
"@mdit-vue/plugin-component": "^2.1.0",
"@mdit-vue/plugin-frontmatter": "^2.1.0",
"@mdit-vue/plugin-headers": "^2.1.0",
"@mdit-vue/plugin-sfc": "^2.1.0",
"@mdit-vue/plugin-title": "^2.1.0",
"@mdit-vue/plugin-toc": "^2.1.0",
"@mdit-vue/shared": "^2.1.0",
"@polka/compression": "1.0.0-next.25",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-commonjs": "^25.0.7",
@ -221,6 +221,10 @@
},
"overrides": {
"ora>string-width": "^5"
},
"patchedDependencies": {
"@types/markdown-it@14.0.0": "patches/@types__markdown-it@14.0.0.patch",
"markdown-it-anchor@8.6.7": "patches/markdown-it-anchor@8.6.7.patch"
}
}
}

@ -0,0 +1,13 @@
diff --git a/package.json b/package.json
index 46d7bfb79a36d8090d98d1ea1e36216137e00072..7bc1e8be5f1c5b74f52f7fa08935d2df3d19d3e2 100644
--- a/package.json
+++ b/package.json
@@ -27,7 +27,7 @@
}
],
"main": "",
- "types": "index.d.ts",
+ "types": "index.d.mts",
"exports": {
".": {
"import": "./index.d.mts",

@ -0,0 +1,29 @@
diff --git a/types/index.d.ts b/types/index.d.ts
index 7c94aae194faa66ca006ace98cdb0dee82a3e471..0377cace7c4a9653d4ecf963babffd4bd68494b0 100644
--- a/types/index.d.ts
+++ b/types/index.d.ts
@@ -1,10 +1,10 @@
-import MarkdownIt = require('markdown-it');
-import Token = require('markdown-it/lib/token');
-import State = require('markdown-it/lib/rules_core/state_core');
+import MarkdownIt from 'markdown-it';
+import Token from 'markdown-it/lib/token.mjs';
+import StateCore from 'markdown-it/lib/rules_core/state_core.mjs';
declare namespace anchor {
- export type RenderHref = (slug: string, state: State) => string;
- export type RenderAttrs = (slug: string, state: State) => Record<string, string | number>;
+ export type RenderHref = (slug: string, state: StateCore) => string;
+ export type RenderAttrs = (slug: string, state: StateCore) => Record<string, string | number>;
export interface PermalinkOptions {
class?: string,
@@ -37,7 +37,7 @@ declare namespace anchor {
placement?: 'before' | 'after'
}
- export type PermalinkGenerator = (slug: string, opts: PermalinkOptions, state: State, index: number) => void;
+ export type PermalinkGenerator = (slug: string, opts: PermalinkOptions, state: StateCore, index: number) => void;
export interface AnchorInfo {
slug: string;

@ -7,6 +7,14 @@ settings:
overrides:
ora>string-width: ^5
patchedDependencies:
'@types/markdown-it@14.0.0':
hash: 324uktmxmvfeckydcv3tuzbvze
path: patches/@types__markdown-it@14.0.0.patch
markdown-it-anchor@8.6.7:
hash: 7jac6clbacexfaqdjyv4p6a5n4
path: patches/markdown-it-anchor@8.6.7.patch
importers:
.:
@ -24,8 +32,8 @@ importers:
specifier: ^1.2.4
version: 1.2.4
'@types/markdown-it':
specifier: ^13.0.7
version: 13.0.7
specifier: ^14.0.0
version: 14.0.0(patch_hash=324uktmxmvfeckydcv3tuzbvze)
'@vitejs/plugin-vue':
specifier: ^5.0.4
version: 5.0.4(vite@5.2.8)(vue@3.4.21)
@ -61,26 +69,26 @@ importers:
specifier: ^0.7.0
version: 0.7.0
'@mdit-vue/plugin-component':
specifier: 2.0.0
version: 2.0.0
specifier: ^2.1.0
version: 2.1.0
'@mdit-vue/plugin-frontmatter':
specifier: 2.0.0
version: 2.0.0
specifier: ^2.1.0
version: 2.1.0
'@mdit-vue/plugin-headers':
specifier: 2.0.0
version: 2.0.0
specifier: ^2.1.0
version: 2.1.0
'@mdit-vue/plugin-sfc':
specifier: 2.0.0
version: 2.0.0
specifier: ^2.1.0
version: 2.1.0
'@mdit-vue/plugin-title':
specifier: 2.0.0
version: 2.0.0
specifier: ^2.1.0
version: 2.1.0
'@mdit-vue/plugin-toc':
specifier: 2.0.0
version: 2.0.0
specifier: ^2.1.0
version: 2.1.0
'@mdit-vue/shared':
specifier: 2.0.0
version: 2.0.0
specifier: ^2.1.0
version: 2.1.0
'@polka/compression':
specifier: 1.0.0-next.25
version: 1.0.0-next.25
@ -191,7 +199,7 @@ importers:
version: 14.1.0
markdown-it-anchor:
specifier: ^8.6.7
version: 8.6.7(@types/markdown-it@13.0.7)(markdown-it@14.1.0)
version: 8.6.7(patch_hash=7jac6clbacexfaqdjyv4p6a5n4)(@types/markdown-it@14.0.0)(markdown-it@14.1.0)
markdown-it-attrs:
specifier: ^4.1.6
version: 4.1.6(markdown-it@14.1.0)
@ -830,67 +838,67 @@ packages:
- supports-color
dev: true
/@mdit-vue/plugin-component@2.0.0:
resolution: {integrity: sha512-cTRxlocav/+mfgDcp0P2z/gWuWBez+iNuN4D+b74LpX4AR6UAx2ZvWtCrUZ8VXrO4eCt1/G0YC/Af7mpIb3aoQ==}
/@mdit-vue/plugin-component@2.1.0:
resolution: {integrity: sha512-C3y7/hB90WcCpuxw+Z7uWmF3+NJpjv89PI8EVdxFJMFUfdX9JGBAkW34UA9+JdQSx7ARVeXgcb06zkD5z37cbw==}
dependencies:
'@types/markdown-it': 13.0.7
'@types/markdown-it': 14.0.0(patch_hash=324uktmxmvfeckydcv3tuzbvze)
markdown-it: 14.1.0
dev: true
/@mdit-vue/plugin-frontmatter@2.0.0:
resolution: {integrity: sha512-/LrT6E60QI4XV4mqx3J87hqYXlR7ZyMvndmftR2RGz7cRAwa/xL+kyFLlgrMxkBIKitOShKa3LS/9Ov9b0fU+g==}
/@mdit-vue/plugin-frontmatter@2.1.0:
resolution: {integrity: sha512-vVDjrv1RZorGo1yW7PZg7/dwRupSBzMt8YE8mmM+TMA0NtFEhYfWdHj8vWgkXm1ZJUugmXheL6SxJzo6fz6uHA==}
dependencies:
'@mdit-vue/types': 2.0.0
'@types/markdown-it': 13.0.7
'@mdit-vue/types': 2.1.0
'@types/markdown-it': 14.0.0(patch_hash=324uktmxmvfeckydcv3tuzbvze)
gray-matter: 4.0.3
markdown-it: 14.1.0
dev: true
/@mdit-vue/plugin-headers@2.0.0:
resolution: {integrity: sha512-ITMMPCnLEYHHgj3XEUL2l75jsNn8guxNqr26YrMSi1f5zcgq4XVy1LIvfwvJ1puqM6Cc5v4BHk3oAyorAi7l1A==}
/@mdit-vue/plugin-headers@2.1.0:
resolution: {integrity: sha512-vau2AtVIN+nqjlMrvYOpz2toBkJJGUcqJY48Mlo33YybBYNDRCBrX/1VFWJ++B3IeJpdFFMLwhZvRN5tsuhPhQ==}
dependencies:
'@mdit-vue/shared': 2.0.0
'@mdit-vue/types': 2.0.0
'@types/markdown-it': 13.0.7
'@mdit-vue/shared': 2.1.0
'@mdit-vue/types': 2.1.0
'@types/markdown-it': 14.0.0(patch_hash=324uktmxmvfeckydcv3tuzbvze)
markdown-it: 14.1.0
dev: true
/@mdit-vue/plugin-sfc@2.0.0:
resolution: {integrity: sha512-OXrMXOyk0iwdIou2jRoIHIbjskwghkO14C9/OjgVHXSSX+iM/WQ4l4yi1aWmNlbQNjtP8IXcVAyJB9K0DFYmLg==}
/@mdit-vue/plugin-sfc@2.1.0:
resolution: {integrity: sha512-7M07z3sADHQXwf9CuOXQBK4+Ga+wxnyTNrwsuk0knnvXRO7l6N6yL5sPgzgz67e4UBsqDwsxgWzTgsnzmv6OMg==}
dependencies:
'@mdit-vue/types': 2.0.0
'@types/markdown-it': 13.0.7
'@mdit-vue/types': 2.1.0
'@types/markdown-it': 14.0.0(patch_hash=324uktmxmvfeckydcv3tuzbvze)
markdown-it: 14.1.0
dev: true
/@mdit-vue/plugin-title@2.0.0:
resolution: {integrity: sha512-eqBoETPVkMXNLvwFshz/A2+Cz81VB5HEkXDm0tt6RBW/rTvnoWmGJ1Z+mvcjR5ck5W4nYdIyT68oHxX2JI2M4g==}
/@mdit-vue/plugin-title@2.1.0:
resolution: {integrity: sha512-16KmXwMnWxDwj6CelA1Fyf12/OYvkA2c2MN1iFAdJQnK7wOSPcUscdVO7nxverThuPQLENt/8500/AJqjH4/3Q==}
dependencies:
'@mdit-vue/shared': 2.0.0
'@mdit-vue/types': 2.0.0
'@types/markdown-it': 13.0.7
'@mdit-vue/shared': 2.1.0
'@mdit-vue/types': 2.1.0
'@types/markdown-it': 14.0.0(patch_hash=324uktmxmvfeckydcv3tuzbvze)
markdown-it: 14.1.0
dev: true
/@mdit-vue/plugin-toc@2.0.0:
resolution: {integrity: sha512-PKQ8sZna3D5chTnt2lxL+ddpyXd++6Nyc0l8VXCeDgStlySQwiP9jaLeeC88oqY4BtRu4cAmILmxDrvuX0Rrdg==}
/@mdit-vue/plugin-toc@2.1.0:
resolution: {integrity: sha512-CUVIHELx73yPypYKvnG+6cwjudUCq5vqXOCb3HfFQOICVXk9Y5W0MFOnGBcyt2JxY4D1dUWusj3YT4o0MDm/Eg==}
dependencies:
'@mdit-vue/shared': 2.0.0
'@mdit-vue/types': 2.0.0
'@types/markdown-it': 13.0.7
'@mdit-vue/shared': 2.1.0
'@mdit-vue/types': 2.1.0
'@types/markdown-it': 14.0.0(patch_hash=324uktmxmvfeckydcv3tuzbvze)
markdown-it: 14.1.0
dev: true
/@mdit-vue/shared@2.0.0:
resolution: {integrity: sha512-PdxpQpbyTazeo2JT87qms6RPZIzyJd+gwuB+1jSwLDI7+0u5g79y2XgTAbZromSVgY2f3UU5HWdwaLbV9w4uOw==}
/@mdit-vue/shared@2.1.0:
resolution: {integrity: sha512-eLPdmaB9f7VGjC6AzA5Q2pOzj1s5uJMtF+925SQTjlZIzlJbv1KFwjcO57dlr8aOzF1XrWm8j8nB1qYlecW4Ig==}
dependencies:
'@mdit-vue/types': 2.0.0
'@types/markdown-it': 13.0.7
'@mdit-vue/types': 2.1.0
'@types/markdown-it': 14.0.0(patch_hash=324uktmxmvfeckydcv3tuzbvze)
markdown-it: 14.1.0
dev: true
/@mdit-vue/types@2.0.0:
resolution: {integrity: sha512-1BeEB+DbtmDMUAfvbNUj5Hso8cSl2sBVK2iTyOMAqhfDVLdh+/9+D0JmQHaCeUk/vuJoMhOwbweZvh55wHxm4w==}
/@mdit-vue/types@2.1.0:
resolution: {integrity: sha512-TMBB/BQWVvwtpBdWD75rkZx4ZphQ6MN0O4QB2Bc0oI5PC2uE57QerhNxdRZ7cvBHE2iY2C+BUNUziCfJbjIRRA==}
dev: true
/@nodelib/fs.scandir@2.1.5:
@ -1222,26 +1230,27 @@ packages:
/@types/markdown-it-attrs@4.1.3:
resolution: {integrity: sha512-1JsseFdHD6rQHsPcy4W3xx/whxvZ09Z+CqPpnOtrGtpmkFW07N11q7oM383//LtoKv54yn+HGnk6r4ZHUTHJVg==}
dependencies:
'@types/markdown-it': 13.0.7
'@types/markdown-it': 14.0.0(patch_hash=324uktmxmvfeckydcv3tuzbvze)
dev: true
/@types/markdown-it-container@2.0.10:
resolution: {integrity: sha512-zv+YxrlSYRq51e9kzm3orv4OvF4U79Ll1OyplNXr00o4ZC/8PukJk/jEWH7CnsMtrSWZlyv0czhz42jm9J4uLw==}
dependencies:
'@types/markdown-it': 13.0.7
'@types/markdown-it': 14.0.0(patch_hash=324uktmxmvfeckydcv3tuzbvze)
dev: true
/@types/markdown-it-emoji@2.0.5:
resolution: {integrity: sha512-iJLsmCNpSWKtV6Ia3mLSjcXJPEt7ubGG342z+hGvYx++TpM19oTUrJcI7XjbOqRQ+W2UQ323E7B0eCLwlgT/9g==}
dependencies:
'@types/markdown-it': 13.0.7
'@types/markdown-it': 14.0.0(patch_hash=324uktmxmvfeckydcv3tuzbvze)
dev: true
/@types/markdown-it@13.0.7:
resolution: {integrity: sha512-U/CBi2YUUcTHBt5tjO2r5QV/x0Po6nsYwQU4Y04fBS6vfoImaiZ6f8bi3CjTCxBPQSO1LMyUqkByzi8AidyxfA==}
/@types/markdown-it@14.0.0(patch_hash=324uktmxmvfeckydcv3tuzbvze):
resolution: {integrity: sha512-2rStaAqMaLQNfo9mg2HNlley75jUTAkZKqlk3pxDSgaFk44zd+CAVpczpoh6/RtOzfUtwpEyD6lsHWUfKbVSDg==}
dependencies:
'@types/linkify-it': 3.0.5
'@types/mdurl': 1.0.5
patched: true
/@types/mdurl@1.0.5:
resolution: {integrity: sha512-6L6VymKTzYSrEf4Nev4Xa1LCHKrlTlYCBMTlQKFuddo1CvQcE52I0mwfOJayueUC7MJuXOeHTcIU683lzd0cUA==}
@ -3353,15 +3362,16 @@ packages:
resolution: {integrity: sha512-1I+1qpDt4idfgLQG+BNWmrqku+7/2bi5nLf4YwF8y8zXvmfiTBY3PV3ZibfrjBueCByROpuBjLLFCajqkgYoLQ==}
dev: false
/markdown-it-anchor@8.6.7(@types/markdown-it@13.0.7)(markdown-it@14.1.0):
/markdown-it-anchor@8.6.7(patch_hash=7jac6clbacexfaqdjyv4p6a5n4)(@types/markdown-it@14.0.0)(markdown-it@14.1.0):
resolution: {integrity: sha512-FlCHFwNnutLgVTflOYHPW2pPcl2AACqVzExlkGQNsi4CJgqOHN7YTgDd4LuhgN1BFO3TS0vLAruV1Td6dwWPJA==}
peerDependencies:
'@types/markdown-it': '*'
markdown-it: '*'
dependencies:
'@types/markdown-it': 13.0.7
'@types/markdown-it': 14.0.0(patch_hash=324uktmxmvfeckydcv3tuzbvze)
markdown-it: 14.1.0
dev: true
patched: true
/markdown-it-attrs@4.1.6(markdown-it@14.1.0):
resolution: {integrity: sha512-O7PDKZlN8RFMyDX13JnctQompwrrILuz2y43pW2GagcwpIIElkAdfeek+erHfxUOlXWPsjFeWmZ8ch1xtRLWpA==}

@ -15,9 +15,10 @@ import { titlePlugin } from '@mdit-vue/plugin-title'
import { tocPlugin, type TocPluginOptions } from '@mdit-vue/plugin-toc'
import { slugify } from '@mdit-vue/shared'
import MarkdownIt from 'markdown-it'
import type { Options } from 'markdown-it'
import anchorPlugin from 'markdown-it-anchor'
import attrsPlugin from 'markdown-it-attrs'
// @ts-ignore
// @ts-expect-error: types of markdown-it-emoji are not up-to-date
import { full as emojiPlugin } from 'markdown-it-emoji'
import type {
BuiltinTheme,
@ -47,7 +48,7 @@ export type ThemeOptions =
dark: ThemeRegistrationAny | BuiltinTheme
}
export interface MarkdownOptions extends MarkdownIt.Options {
export interface MarkdownOptions extends Options {
/* ==================== General Options ==================== */
/**

@ -1,6 +1,6 @@
import type MarkdownIt from 'markdown-it'
import type { RenderRule } from 'markdown-it/lib/renderer'
import type Token from 'markdown-it/lib/token'
import type { RenderRule } from 'markdown-it/lib/renderer.mjs'
import type Token from 'markdown-it/lib/token.mjs'
import container from 'markdown-it-container'
import { nanoid } from 'nanoid'
import {

@ -1,6 +1,6 @@
import fs from 'fs-extra'
import type MarkdownIt from 'markdown-it'
import type { RuleBlock } from 'markdown-it/lib/parser_block'
import type ParserBlock from 'markdown-it/lib/parser_block.mjs'
import path from 'path'
import type { MarkdownEnv } from '../../shared'
@ -98,7 +98,7 @@ function findRegion(lines: Array<string>, regionName: string) {
}
export const snippetPlugin = (md: MarkdownIt, srcDir: string) => {
const parser: RuleBlock = (state, startLine, endLine, silent) => {
const parser: ParserBlock.RuleBlock = (state, startLine, endLine, silent) => {
const CH = '<'.charCodeAt(0)
const pos = state.bMarks[startLine] + state.tShift[startLine]
const max = state.eMarks[startLine]

Loading…
Cancel
Save