Skip to content

Commit

Permalink
feat(md-enhance): extract plugins and use @mdit/plugin-xxx
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `imageLazyload` is renamed to `imgLazyload`
`imageSize` is renamed to `imgSize`
`imageMark` is renamed to `imgMark`
  • Loading branch information
Mister-Hope committed Dec 28, 2022
1 parent 94cf916 commit 6e91afe
Show file tree
Hide file tree
Showing 98 changed files with 400 additions and 7,523 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Expand Up @@ -62,6 +62,7 @@
"livescript",
"mailchimp",
"mathjax",
"mdit",
"npmmirror",
"nprogress",
"pandoc",
Expand Down
6 changes: 3 additions & 3 deletions demo/md-enhance/src/.vuepress/config.ts
Expand Up @@ -71,9 +71,9 @@ export default defineUserConfig({
figure: true,
flowchart: true,
gfm: true,
imageLazyload: true,
imageMark: true,
imageSize: true,
imgLazyload: true,
imgMark: true,
imgSize: true,
include: true,
mark: true,
mermaid: true,
Expand Down
4 changes: 2 additions & 2 deletions demo/theme-blog/src/.vuepress/theme.ts
Expand Up @@ -180,8 +180,8 @@ export default hopeTheme({
figure: true,
flowchart: true,
gfm: true,
imageLazyload: true,
imageSize: true,
imgLazyload: true,
imgSize: true,
include: true,
katex: true,
mark: true,
Expand Down
4 changes: 2 additions & 2 deletions demo/theme-docs/src/.vuepress/theme.ts
Expand Up @@ -107,8 +107,8 @@ export default hopeTheme({
figure: true,
flowchart: true,
gfm: true,
imageLazyload: true,
imageSize: true,
imgLazyload: true,
imgSize: true,
include: true,
katex: true,
mark: true,
Expand Down
6 changes: 3 additions & 3 deletions docs/md-enhance/src/.vuepress/theme.ts
Expand Up @@ -27,9 +27,9 @@ export default theme("md-enhance", {
figure: true,
flowchart: true,
gfm: true,
imageLazyload: true,
imageMark: true,
imageSize: true,
imgLazyload: true,
imgMark: true,
imgSize: true,
include: true,
katex: true,
mark: true,
Expand Down
23 changes: 0 additions & 23 deletions docs/md-enhance/src/README.md
Expand Up @@ -177,26 +177,3 @@ export default {
## Migrating from V1

For details, see [Migration Guide](./migration.md).

## Advanced

This plugin exports the following Markdown-it plugin, and you can use them in other projects.

- align
- attrs
- container
- figure
- footnote
- imageLazyload
- imageMark
- imageSize
- include
- mathjax
- katex
- mark
- stylize
- sub
- sup
- tasklist
- tex
- uml
6 changes: 3 additions & 3 deletions docs/md-enhance/src/config.md
Expand Up @@ -166,14 +166,14 @@ Whether to enable mark support.

Whether enable figure support.

## imageLazyload
## imgLazyload

- Type: `boolean`
- Default: `false`

Whether to lazy load every images in page in native way.

## imageMark
## imgMark

- Type: `ImageMarkOptions | boolean`
- Default: `false`
Expand All @@ -189,7 +189,7 @@ interface ImageMarkOptions {
}
```

## imageSize
## imgSize

- Type: `boolean`
- Default: `false`
Expand Down
20 changes: 10 additions & 10 deletions docs/md-enhance/src/guide/image.md
Expand Up @@ -23,11 +23,11 @@ export default {
// Enable figure
figure: true,
// Enable image lazyload
imageLazyload: true,
imgLazyload: true,
// Enable image mark
imageMark: true,
imgMark: true,
// Enable image size
imageSize: true,
imgSize: true,
}),
],
};
Expand All @@ -45,11 +45,11 @@ export default {
// Enable figure
figure: true,
// Enable image lazyload
imageLazyload: true,
imgLazyload: true,
// Enable image mark
imageMark: true,
imgMark: true,
// Enable image size
imageSize: true,
imgSize: true,
}),
],
};
Expand All @@ -59,7 +59,7 @@ export default {

## Image Lazyload

If you want to lazyload images in your pages, you can set `imageLazyload: true` in plugin options.
If you want to lazyload images in your pages, you can set `imgLazyload: true` in plugin options.

::: note

Expand All @@ -71,7 +71,7 @@ We are enabling lazyload using native HTML5 features, so your browser must suppo

GFM supports marking pictures by ID suffix so that pictures are only displayed in a specific mode. We support both GitHub’s markup and the easy markup `#light` and `#dark`.

You can enable it using `imageMark` option.
You can enable it using `imgMark` option.

```md
![GitHub Light](/assets/icon/github-light.png#gh-dark-mode-only)
Expand All @@ -97,7 +97,7 @@ The above demo will render the following result

### Advanced

You can pass an object to `imageMark` to config ID marks, available options are:
You can pass an object to `imgMark` to config ID marks, available options are:

```ts
interface ImageMarkOptions {
Expand All @@ -110,7 +110,7 @@ interface ImageMarkOptions {

## Image Size

You can use `=widthxheight` to specify the image size when setting `imageSize: true` in plugin options.
You can use `=widthxheight` to specify the image size when setting `imgSize: true` in plugin options.

```md
![Alt](/example.png =200x300)
Expand Down
2 changes: 1 addition & 1 deletion docs/md-enhance/src/guide/stylize.md
Expand Up @@ -181,7 +181,7 @@ export default {

:::

If you want to skip some words in some pages, you can set `noStylize` in page frontmatter with an array containing content you don’t want to stylize.
Also, you can use `stylize` in frontmatter to provide extra stylize rules for content of the page.

::: info Performance

Expand Down
2 changes: 1 addition & 1 deletion docs/md-enhance/src/migration.md
Expand Up @@ -17,7 +17,7 @@ You can pass the second argument `true` to enable legacy mode when calling `mdEn

- image mark support

Use `#light` and `#dark` suffix to mark images to display them in light mode or dark mode via `imageMark` option.
Use `#light` and `#dark` suffix to mark images to display them in light mode or dark mode via `imgMark` option.

- `v-pre` support

Expand Down
23 changes: 0 additions & 23 deletions docs/md-enhance/src/zh/README.md
Expand Up @@ -179,26 +179,3 @@ export default {
## 从 V1 迁移

详见 [迁移指南](./migration.md)

## 高级用法

这个插件导出了以下 markdown-it 插件,你可以在其他项目中使用它们。

- align
- attrs
- container
- figure
- footnote
- imageLazyload
- imageMark
- imageSize
- include
- mathjax
- katex
- mark
- stylize
- sub
- sup
- tasklist
- tex
- uml
6 changes: 3 additions & 3 deletions docs/md-enhance/src/zh/config.md
Expand Up @@ -166,14 +166,14 @@ icon: config

是否启用图片 Figure 支持。

## imageLazyload
## imgLazyload

- 类型: `boolean`
- 默认值: `false`

是否使用原生方式懒加载页面图片。

## imageMark
## imgMark

- 类型: `ImageMarkOptions | boolean`
- 默认值: `false`
Expand All @@ -189,7 +189,7 @@ interface ImageMarkOptions {
}
```

## imageSize
## imgSize

- 类型: `boolean`
- 默认值: `false`
Expand Down
20 changes: 10 additions & 10 deletions docs/md-enhance/src/zh/guide/image.md
Expand Up @@ -23,11 +23,11 @@ export default {
// 启用 figure
figure: true,
// 启用图片懒加载
imageLazyload: true,
imgLazyload: true,
// 启用图片标记
imageMark: true,
imgMark: true,
// 启用图片大小
imageSize: true,
imgSize: true,
}),
],
};
Expand All @@ -45,11 +45,11 @@ export default {
// 启用 figure
figure: true,
// 启用图片懒加载
imageLazyload: true,
imgLazyload: true,
// 启用图片标记
imageMark: true,
imgMark: true,
// 启用图片大小
imageSize: true,
imgSize: true,
}),
],
};
Expand All @@ -59,7 +59,7 @@ export default {

## 图片懒加载

如果你想在你的页面中延迟加载图片,你可以在插件选项中设置 `imageLazyload: true`
如果你想在你的页面中延迟加载图片,你可以在插件选项中设置 `imgLazyload: true`

::: note

Expand All @@ -71,7 +71,7 @@ export default {

GFM 支持通过 ID 标记图片,使得图片只在特定的模式显示。我们同时支持 GitHub 的标记与简易标记 `#light``#dark`

你可以通过 `imageMark` 选项控制它。
你可以通过 `imgMark` 选项控制它。

```md
![GitHub Light](/assets/icon/github-light.png#gh-dark-mode-only)
Expand All @@ -97,7 +97,7 @@ GFM 支持通过 ID 标记图片,使得图片只在特定的模式显示。我

### 高级用法

你可以将对象传递给 `imageMark` 以配置 ID 标记,可用选项有:
你可以将对象传递给 `imgMark` 以配置 ID 标记,可用选项有:

```ts
interface ImageMarkOptions {
Expand All @@ -110,7 +110,7 @@ interface ImageMarkOptions {

## 图片尺寸

当你在插件选项中设置 `imageSize: true` 时,可以使用 `=widthxheight` 指定图像大小。
当你在插件选项中设置 `imgSize: true` 时,可以使用 `=widthxheight` 指定图像大小。

```md
![Alt](/example.png =200x300)
Expand Down
2 changes: 1 addition & 1 deletion docs/md-enhance/src/zh/guide/stylize.md
Expand Up @@ -181,7 +181,7 @@ export default {

:::

如果你想跳过某些页面中的某些单词,你可以在页面 frontmatter 中设置 `noStylize` 数组,并放置你不想风格化的内容
同时,你也可以在 frontmatter 总通过 `stylize` 选项来自定义此页面额外的匹配标记的函数

::: info 性能

Expand Down
2 changes: 1 addition & 1 deletion docs/md-enhance/src/zh/migration.md
Expand Up @@ -17,7 +17,7 @@ icon: change

- 图像标记支持

通过 `imageMark` 选项使用 `#light``#dark` 后缀标记图像以在日间模式或夜间模式下显示它们。
通过 `imgMark` 选项使用 `#light``#dark` 后缀标记图像以在日间模式或夜间模式下显示它们。

- `v-pre` 支持

Expand Down
6 changes: 3 additions & 3 deletions docs/theme/src/.vuepress/theme.ts
Expand Up @@ -105,9 +105,9 @@ export default hopeTheme({
figure: true,
flowchart: true,
gfm: true,
imageLazyload: true,
imageMark: true,
imageSize: true,
imgLazyload: true,
imgMark: true,
imgSize: true,
include: true,
katex: true,
mark: true,
Expand Down
4 changes: 2 additions & 2 deletions docs/theme/src/config/plugins/md-enhance.md
Expand Up @@ -147,7 +147,7 @@ Whether to enable mark support.

Whether enable figure support.

### imageMark
### imgMark

- Type: `ImageMarkOptions | boolean`
- Default: `false`
Expand All @@ -163,7 +163,7 @@ interface ImageMarkOptions {
}
```

### imageSize
### imgSize

- Type: `boolean`
- Default: `false`
Expand Down

0 comments on commit 6e91afe

Please sign in to comment.