图片
Mr.Hope ... 2022-6-4 大约 1 分钟
改进 Markdown 中的图像语法以支持颜色方案和大小。
# 配置
module.exports = {
plugins: [
[
"md-enhance",
{
// 启用图片标记
imageMark: true,
// 启用图片大小
imageSize: true,
},
],
],
};
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
# 图片 ID 标记
GFM 支持通过 ID 标记图片,使得图片只在特定的模式显示。我们同时支持 GitHub 的标记与简易标记 #light
和 #dark
。
你可以通过 imageMark
选项控制它。




1
2
3
4
5
2
3
4
5
案例
上述演示会渲染如下结果
# 高级用法
你可以将对象传递给 imageMark
以配置 ID 标记,可用选项有:
interface ImageMarkOptions {
/** 仅限日间模式的 ID */
light?: string[];
/** 仅限夜间模式的 ID */
dark?: string[];
}
1
2
3
4
5
6
2
3
4
5
6
# 图片尺寸
当你在插件选项中设置 imageSize: true
时,可以使用 =widthxheight
指定图像大小。



1
2
3
4
2
3
4
上面的 Markdown 将被解析为:
<img src="/example.png" width="200" height="300" />
<img src="/example.jpg" title="图片标题" width="200" />
<img src="/example.bmp" height="300" />
1
2
3
2
3