diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fdb71325..cf7f3d0e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -313,6 +313,12 @@ importers: '@vuepress/plugin-markdown-hint': specifier: 2.0.0-rc.46 version: 2.0.0-rc.46(markdown-it@14.1.0)(typescript@5.6.2)(vuepress@2.0.0-rc.15(@vuepress/bundler-vite@2.0.0-rc.15(@types/node@20.14.8)(jiti@1.21.6)(sass@1.77.8)(tsx@4.16.0)(typescript@5.6.2)(yaml@2.5.0))(typescript@5.6.2)(vue@3.5.7(typescript@5.6.2))) + '@vuepress/plugin-markdown-image': + specifier: 2.0.0-rc.46 + version: 2.0.0-rc.46(markdown-it@14.1.0)(typescript@5.6.2)(vuepress@2.0.0-rc.15(@vuepress/bundler-vite@2.0.0-rc.15(@types/node@20.14.8)(jiti@1.21.6)(sass@1.77.8)(tsx@4.16.0)(typescript@5.6.2)(yaml@2.5.0))(typescript@5.6.2)(vue@3.5.7(typescript@5.6.2))) + '@vuepress/plugin-markdown-math': + specifier: 2.0.0-rc.46 + version: 2.0.0-rc.46(katex@0.16.11)(markdown-it@14.1.0)(typescript@5.6.2)(vuepress@2.0.0-rc.15(@vuepress/bundler-vite@2.0.0-rc.15(@types/node@20.14.8)(jiti@1.21.6)(sass@1.77.8)(tsx@4.16.0)(typescript@5.6.2)(yaml@2.5.0))(typescript@5.6.2)(vue@3.5.7(typescript@5.6.2))) '@vuepress/plugin-nprogress': specifier: 2.0.0-rc.46 version: 2.0.0-rc.46(typescript@5.6.2)(vuepress@2.0.0-rc.15(@vuepress/bundler-vite@2.0.0-rc.15(@types/node@20.14.8)(jiti@1.21.6)(sass@1.77.8)(tsx@4.16.0)(typescript@5.6.2)(yaml@2.5.0))(typescript@5.6.2)(vue@3.5.7(typescript@5.6.2))) @@ -1173,6 +1179,15 @@ packages: markdown-it: optional: true + '@mdit/plugin-figure@0.13.1': + resolution: {integrity: sha512-bxeUVMPAuXHYRqPzU+1ux7R3LkpyHTdavCa05rQUhzDI07N+BZDE7oOABXnnFbx6ESamzu3/FBtq9VKjoifLmw==} + engines: {node: '>= 18'} + peerDependencies: + markdown-it: ^14.1.0 + peerDependenciesMeta: + markdown-it: + optional: true + '@mdit/plugin-footnote@0.12.0': resolution: {integrity: sha512-9B+bJdMndCPoA9De9bxRm4/fyz02PHRcttOyuyPJ3G+wCAgIN1c/7CB8ViT1YJuECUjLogJQ/rrgqh7f0LTqLQ==} engines: {node: '>= 18'} @@ -1188,6 +1203,15 @@ packages: markdown-it: optional: true + '@mdit/plugin-img-lazyload@0.13.1': + resolution: {integrity: sha512-DPzR+yabbgqHWHb8oetOj56TtZzOcn5YZjSTssoh7lY5hp/Yy7jWvlLDrSw/LiXkYEhyocUee78enhTodBEpHQ==} + engines: {node: '>= 18'} + peerDependencies: + markdown-it: ^14.1.0 + peerDependenciesMeta: + markdown-it: + optional: true + '@mdit/plugin-img-mark@0.12.0': resolution: {integrity: sha512-HkIUwlTg/xPsBi4PG+5dsMnsb7wdiJzELSCEUfdAJTg55nksonHfyV2pFpr87MML4nuZlZK9JHt+Bm2BBDSVSw==} engines: {node: '>= 18'} @@ -1197,6 +1221,15 @@ packages: markdown-it: optional: true + '@mdit/plugin-img-mark@0.13.1': + resolution: {integrity: sha512-HOALB1nILV5vkopSKPrclkwwc5WGbpuAWxuOLTz/teOifE8E4JsbiFivcM6URMP1lZXzRBXoniQCCOUhWRis8A==} + engines: {node: '>= 18'} + peerDependencies: + markdown-it: ^14.1.0 + peerDependenciesMeta: + markdown-it: + optional: true + '@mdit/plugin-img-size@0.12.0': resolution: {integrity: sha512-fCcF5gc+ba6gQ5ebrKuI8bK/gFbj8mbeN45FHmBsFDFsfTHa0Xij2v8iok0nP8YEIVj71y8XYojsqCWs6avong==} engines: {node: '>= 18'} @@ -1206,6 +1239,15 @@ packages: markdown-it: optional: true + '@mdit/plugin-img-size@0.13.1': + resolution: {integrity: sha512-cgihl72BNzij7GXjrqcKhl2eOqAlqWHiImOgblJPghDFNFKnnynty/Bf9nwbj8hTnhVWznFeuwawzXBfKYNbkg==} + engines: {node: '>= 18'} + peerDependencies: + markdown-it: ^14.1.0 + peerDependenciesMeta: + markdown-it: + optional: true + '@mdit/plugin-include@0.12.0': resolution: {integrity: sha512-8pnmp7s1TjbtoBIa/YhYpEivOpeVSyhkQoQrGq1UoaEcTbXqmFwShGkAW3zUYZVFYTl74PgL/UqJnrUojegJQg==} peerDependencies: @@ -1226,6 +1268,18 @@ packages: markdown-it: optional: true + '@mdit/plugin-katex-slim@0.13.1': + resolution: {integrity: sha512-OO4n51aLo0Igv0aICXOaTO5+ZW/jW8Lnl8u1kxs2zkFVNUqpqNHAo8l4QxtscQk5L4XhXGgaTj2ZgAv7rtH96Q==} + engines: {node: '>= 18'} + peerDependencies: + katex: ^0.16.9 + markdown-it: ^14.1.0 + peerDependenciesMeta: + katex: + optional: true + markdown-it: + optional: true + '@mdit/plugin-mark@0.12.0': resolution: {integrity: sha512-BDFwbV/tbgUGL8KF2ymYNLEXT2KNBLe8D0rshDrbB4Iko1U2DywACQkmaUbYBJ1VCn7/dff35at9fWrm3QjrwQ==} engines: {node: '>= 18'} @@ -1247,6 +1301,18 @@ packages: mathjax-full: optional: true + '@mdit/plugin-mathjax-slim@0.13.1': + resolution: {integrity: sha512-ZFtKG2BtLAk1BarJZei9HP4aK0vNU7YvDb+R+nApK7MRmLQ53xHe7upu3qlfNBoOZWHXsdRmcz0G4xL3oxzlqA==} + engines: {node: '>= 18'} + peerDependencies: + markdown-it: ^14.1.0 + mathjax-full: ^3.2.2 + peerDependenciesMeta: + markdown-it: + optional: true + mathjax-full: + optional: true + '@mdit/plugin-plantuml@0.12.0': resolution: {integrity: sha512-m1pk6PA9+kWUs8kylLqjnQ7Lex68x3c4Ato8zAh+omkhugfWzuQXfFiXRiJ9C7wkdqHoJx/E5XobP3HJnhCpoA==} peerDependencies: @@ -1317,6 +1383,15 @@ packages: markdown-it: optional: true + '@mdit/plugin-tex@0.13.1': + resolution: {integrity: sha512-lkRf6XrfVfS11FzT3hiooWdOUPJfAd/cnAv4NN/4WU7qOEz0e0HBVQO8PQb5CPwrE94Ld4+E6rQwJfVH1grkwQ==} + engines: {node: '>= 18'} + peerDependencies: + markdown-it: ^14.1.0 + peerDependenciesMeta: + markdown-it: + optional: true + '@mdit/plugin-uml@0.12.0': resolution: {integrity: sha512-EfVMmq0CwLJcssxhkvGS2ESenNNEMeK04j702Z9v3am1M9DdEj6zHTrHQd9tA0jNVuFY8ZlmMgDfkkG5k6Rm3Q==} engines: {node: '>= 18'} @@ -2003,6 +2078,23 @@ packages: peerDependencies: vuepress: 2.0.0-rc.15 + '@vuepress/plugin-markdown-image@2.0.0-rc.46': + resolution: {integrity: sha512-GwBmAxjeqCDSJi8I/wjTTovo1EVcTE9JrTZepD6wYKIQa3OwnSdzcwUXPhzViwysgsKpWhOchnmxHVlp7KAlnA==} + peerDependencies: + vuepress: 2.0.0-rc.15 + + '@vuepress/plugin-markdown-math@2.0.0-rc.46': + resolution: {integrity: sha512-nkcvq11PAQb0snkPKBNRdN7yJXiodwu6ftSK2NnRTm9izm5qkUllrk3c3A2OqLdjmLQMBv5uPlDpFPdZz9XzjQ==} + peerDependencies: + katex: ^0.16.10 + mathjax-full: ^3.2.2 + vuepress: 2.0.0-rc.15 + peerDependenciesMeta: + katex: + optional: true + mathjax-full: + optional: true + '@vuepress/plugin-nprogress@2.0.0-rc.46': resolution: {integrity: sha512-lSVW3+76ny4etghttPy6PR6At4g8vmrOh47gwXXmNAWoSuB0FPQPIbBggaj2nXpEA7KN2JOPa1QGGMrFuunvbg==} peerDependencies: @@ -6597,6 +6689,12 @@ snapshots: optionalDependencies: markdown-it: 14.1.0 + '@mdit/plugin-figure@0.13.1(markdown-it@14.1.0)': + dependencies: + '@types/markdown-it': 14.1.2 + optionalDependencies: + markdown-it: 14.1.0 + '@mdit/plugin-footnote@0.12.0(markdown-it@14.1.0)': dependencies: '@types/markdown-it': 14.1.2 @@ -6608,18 +6706,36 @@ snapshots: optionalDependencies: markdown-it: 14.1.0 + '@mdit/plugin-img-lazyload@0.13.1(markdown-it@14.1.0)': + dependencies: + '@types/markdown-it': 14.1.2 + optionalDependencies: + markdown-it: 14.1.0 + '@mdit/plugin-img-mark@0.12.0(markdown-it@14.1.0)': dependencies: '@types/markdown-it': 14.1.2 optionalDependencies: markdown-it: 14.1.0 + '@mdit/plugin-img-mark@0.13.1(markdown-it@14.1.0)': + dependencies: + '@types/markdown-it': 14.1.2 + optionalDependencies: + markdown-it: 14.1.0 + '@mdit/plugin-img-size@0.12.0(markdown-it@14.1.0)': dependencies: '@types/markdown-it': 14.1.2 optionalDependencies: markdown-it: 14.1.0 + '@mdit/plugin-img-size@0.13.1(markdown-it@14.1.0)': + dependencies: + '@types/markdown-it': 14.1.2 + optionalDependencies: + markdown-it: 14.1.0 + '@mdit/plugin-include@0.12.0(markdown-it@14.1.0)': dependencies: '@types/markdown-it': 14.1.2 @@ -6636,6 +6752,15 @@ snapshots: katex: 0.16.11 markdown-it: 14.1.0 + '@mdit/plugin-katex-slim@0.13.1(katex@0.16.11)(markdown-it@14.1.0)': + dependencies: + '@mdit/plugin-tex': 0.13.1(markdown-it@14.1.0) + '@types/katex': 0.16.7 + '@types/markdown-it': 14.1.2 + optionalDependencies: + katex: 0.16.11 + markdown-it: 14.1.0 + '@mdit/plugin-mark@0.12.0(markdown-it@14.1.0)': dependencies: '@types/markdown-it': 14.1.2 @@ -6650,6 +6775,14 @@ snapshots: optionalDependencies: markdown-it: 14.1.0 + '@mdit/plugin-mathjax-slim@0.13.1(markdown-it@14.1.0)': + dependencies: + '@mdit/plugin-tex': 0.13.1(markdown-it@14.1.0) + '@types/markdown-it': 14.1.2 + upath: 2.0.1 + optionalDependencies: + markdown-it: 14.1.0 + '@mdit/plugin-plantuml@0.12.0(markdown-it@14.1.0)': dependencies: '@mdit/plugin-uml': 0.12.0(markdown-it@14.1.0) @@ -6699,6 +6832,12 @@ snapshots: optionalDependencies: markdown-it: 14.1.0 + '@mdit/plugin-tex@0.13.1(markdown-it@14.1.0)': + dependencies: + '@types/markdown-it': 14.1.2 + optionalDependencies: + markdown-it: 14.1.0 + '@mdit/plugin-uml@0.12.0(markdown-it@14.1.0)': dependencies: '@types/markdown-it': 14.1.2 @@ -7556,6 +7695,35 @@ snapshots: - markdown-it - typescript + '@vuepress/plugin-markdown-image@2.0.0-rc.46(markdown-it@14.1.0)(typescript@5.6.2)(vuepress@2.0.0-rc.15(@vuepress/bundler-vite@2.0.0-rc.15(@types/node@20.14.8)(jiti@1.21.6)(sass@1.77.8)(tsx@4.16.0)(typescript@5.6.2)(yaml@2.5.0))(typescript@5.6.2)(vue@3.5.7(typescript@5.6.2)))': + dependencies: + '@mdit/plugin-figure': 0.13.1(markdown-it@14.1.0) + '@mdit/plugin-img-lazyload': 0.13.1(markdown-it@14.1.0) + '@mdit/plugin-img-mark': 0.13.1(markdown-it@14.1.0) + '@mdit/plugin-img-size': 0.13.1(markdown-it@14.1.0) + '@types/markdown-it': 14.1.2 + '@vuepress/helper': 2.0.0-rc.46(typescript@5.6.2)(vuepress@2.0.0-rc.15(@vuepress/bundler-vite@2.0.0-rc.15(@types/node@20.14.8)(jiti@1.21.6)(sass@1.77.8)(tsx@4.16.0)(typescript@5.6.2)(yaml@2.5.0))(typescript@5.6.2)(vue@3.5.7(typescript@5.6.2))) + vuepress: 2.0.0-rc.15(@vuepress/bundler-vite@2.0.0-rc.15(@types/node@20.14.8)(jiti@1.21.6)(sass@1.77.8)(tsx@4.16.0)(typescript@5.6.2)(yaml@2.5.0))(typescript@5.6.2)(vue@3.5.7(typescript@5.6.2)) + transitivePeerDependencies: + - '@vue/composition-api' + - markdown-it + - typescript + + '@vuepress/plugin-markdown-math@2.0.0-rc.46(katex@0.16.11)(markdown-it@14.1.0)(typescript@5.6.2)(vuepress@2.0.0-rc.15(@vuepress/bundler-vite@2.0.0-rc.15(@types/node@20.14.8)(jiti@1.21.6)(sass@1.77.8)(tsx@4.16.0)(typescript@5.6.2)(yaml@2.5.0))(typescript@5.6.2)(vue@3.5.7(typescript@5.6.2)))': + dependencies: + '@mdit/plugin-katex-slim': 0.13.1(katex@0.16.11)(markdown-it@14.1.0) + '@mdit/plugin-mathjax-slim': 0.13.1(markdown-it@14.1.0) + '@types/markdown-it': 14.1.2 + '@vuepress/helper': 2.0.0-rc.46(typescript@5.6.2)(vuepress@2.0.0-rc.15(@vuepress/bundler-vite@2.0.0-rc.15(@types/node@20.14.8)(jiti@1.21.6)(sass@1.77.8)(tsx@4.16.0)(typescript@5.6.2)(yaml@2.5.0))(typescript@5.6.2)(vue@3.5.7(typescript@5.6.2))) + vue: 3.5.7(typescript@5.6.2) + vuepress: 2.0.0-rc.15(@vuepress/bundler-vite@2.0.0-rc.15(@types/node@20.14.8)(jiti@1.21.6)(sass@1.77.8)(tsx@4.16.0)(typescript@5.6.2)(yaml@2.5.0))(typescript@5.6.2)(vue@3.5.7(typescript@5.6.2)) + optionalDependencies: + katex: 0.16.11 + transitivePeerDependencies: + - '@vue/composition-api' + - markdown-it + - typescript + '@vuepress/plugin-nprogress@2.0.0-rc.46(typescript@5.6.2)(vuepress@2.0.0-rc.15(@vuepress/bundler-vite@2.0.0-rc.15(@types/node@20.14.8)(jiti@1.21.6)(sass@1.77.8)(tsx@4.16.0)(typescript@5.6.2)(yaml@2.5.0))(typescript@5.6.2)(vue@3.5.7(typescript@5.6.2)))': dependencies: '@vuepress/helper': 2.0.0-rc.46(typescript@5.6.2)(vuepress@2.0.0-rc.15(@vuepress/bundler-vite@2.0.0-rc.15(@types/node@20.14.8)(jiti@1.21.6)(sass@1.77.8)(tsx@4.16.0)(typescript@5.6.2)(yaml@2.5.0))(typescript@5.6.2)(vue@3.5.7(typescript@5.6.2))) diff --git a/theme/package.json b/theme/package.json index c655399e..c130d4c6 100644 --- a/theme/package.json +++ b/theme/package.json @@ -63,6 +63,8 @@ }, "peerDependencies": { "@iconify/json": "^2", + "katex": "^0.16.10", + "mathjax-full": "^3.2.2", "swiper": "^11.0.0", "vuepress": "2.0.0-rc.15" }, @@ -70,6 +72,12 @@ "@iconify/json": { "optional": true }, + "katex": { + "optional": true + }, + "mathjax-full": { + "optional": true + }, "swiper": { "optional": true } @@ -90,6 +98,8 @@ "@vuepress/plugin-git": "2.0.0-rc.44", "@vuepress/plugin-markdown-container": "2.0.0-rc.43", "@vuepress/plugin-markdown-hint": "2.0.0-rc.46", + "@vuepress/plugin-markdown-image": "2.0.0-rc.46", + "@vuepress/plugin-markdown-math": "2.0.0-rc.46", "@vuepress/plugin-nprogress": "2.0.0-rc.46", "@vuepress/plugin-photo-swipe": "2.0.0-rc.46", "@vuepress/plugin-reading-time": "2.0.0-rc.46", diff --git a/theme/src/node/plugins/getPlugins.ts b/theme/src/node/plugins/getPlugins.ts index 4afdb656..380a7c03 100644 --- a/theme/src/node/plugins/getPlugins.ts +++ b/theme/src/node/plugins/getPlugins.ts @@ -6,6 +6,8 @@ import { commentPlugin } from '@vuepress/plugin-comment' import { docsearchPlugin } from '@vuepress/plugin-docsearch' import { gitPlugin } from '@vuepress/plugin-git' import { markdownHintPlugin } from '@vuepress/plugin-markdown-hint' +import { markdownImagePlugin } from '@vuepress/plugin-markdown-image' +import { markdownMathPlugin } from '@vuepress/plugin-markdown-math' import { nprogressPlugin } from '@vuepress/plugin-nprogress' import { photoSwipePlugin } from '@vuepress/plugin-photo-swipe' import { readingTimePlugin } from '@vuepress/plugin-reading-time' @@ -121,10 +123,9 @@ export function getPlugins({ sub: true, alert: true, footnote: true, - katex: true, } as MarkdownEnhancePluginOptions, pluginOptions.markdownEnhance || {}, - { hint: false, alert: false } as MarkdownEnhancePluginOptions, + { hint: false, alert: false, imgSize: false, imgLazyload: false, imgMark: false, figure: false, obsidianImgSize: false, katex: false, mathjax: false } as MarkdownEnhancePluginOptions, ), )) } @@ -142,6 +143,14 @@ export function getPlugins({ })) } + if (pluginOptions.markdownMath !== false) { + plugins.push(markdownMathPlugin(pluginOptions.markdownMath ?? { type: 'katex' })) + } + + if (pluginOptions.markdownImage) { + plugins.push(markdownImagePlugin(pluginOptions.markdownImage)) + } + if (pluginOptions.watermark) { plugins.push(watermarkPlugin({ delay: 300, diff --git a/theme/src/shared/options/plugins.ts b/theme/src/shared/options/plugins.ts index 1fbe419d..3e9ff649 100644 --- a/theme/src/shared/options/plugins.ts +++ b/theme/src/shared/options/plugins.ts @@ -1,5 +1,7 @@ import type { CommentPluginOptions } from '@vuepress/plugin-comment' import type { DocSearchOptions } from '@vuepress/plugin-docsearch' +import type { MarkdownImagePluginOptions } from '@vuepress/plugin-markdown-image' +import type { MarkdownMathPluginOptions } from '@vuepress/plugin-markdown-math' import type { ReadingTimePluginOptions } from '@vuepress/plugin-reading-time' import type { WatermarkPluginOptions } from '@vuepress/plugin-watermark' import type { SearchPluginOptions } from '@vuepress-plume/plugin-search' @@ -45,10 +47,39 @@ export interface PlumeThemePluginOptions { photoSwipe?: false - markdownEnhance?: false | MarkdownEnhancePluginOptions + /** + * 是否启用 `vuepress-plugin-md-enhance` 插件 + * + * - `hint`, `alert` 已迁移至 `@vuepress/plugin-markdown-hint`, 且主题内置并默认启用。 + * - `imgSize`, `imgMark`, `imgLazyload`, `figure`, `obsidianImgSize` 已迁移至 `@vuepress/plugin-markdown-image`, 请使用 `plugins.markdownImage` 配置项代替。 + * - `katex`, `mathjax` 已迁移至 `@vuepress/plugin-markdown-math`, 请使用 `plugins.markdownMath` 配置项代替 + */ + markdownEnhance?: + | false + | Omit< + MarkdownEnhancePluginOptions, + 'hint' | 'alert' | 'imgSize' | 'imgMark' | 'imgLazyload' | 'figure' | 'obsidianImgSize' + | 'katex' | 'mathjax' + > markdownPower?: false | MarkdownPowerPluginOptions + /** + * 是否启用 `@vuepress/plugin-markdown-image` 插件 + * + * @default false + * @see https://ecosystem.vuejs.press/zh/plugins/markdown/markdown-image.html + */ + markdownImage?: false | MarkdownImagePluginOptions + + /** + * 是否启用 `@vuepress/plugin-markdown-math` 插件 + * + * @default { type: 'katex' } + * @see https://ecosystem.vuejs.press/zh/plugins/markdown/markdown-math.html + */ + markdownMath?: false | MarkdownMathPluginOptions + comment?: false | CommentPluginOptions sitemap?: false