vscode markdown preview enhanced插件显示图片标题
vscode markdown preview enhanced插件显示图片alt标题注释
编辑 parser.js 文件的 onWillParseMarkdown
或 onDidParseMarkdown
函数
- windows:%userprofile%/.crossnote/parser.js
- linux/mac:~/.crossnote/parser.js
1
2
3
4
5
6
7
8
9
onWillParseMarkdown: async function(markdown) {
markdown = markdown.replace(/!\[(.*?)\]\((.*?)\)/g, (all,alt,src) => `${all}<span style="margin-top:-5px;text-decoration: underline;text-underline-offset:2px;text-decoration-color:#d9d9d9;font-size:13px;text-align:center;display:block;">${alt}</span>`);
return markdown;
},
onDidParseMarkdown: async function(html) {
html = html.replace(/<img src="(.*?)" alt="(.*?)".*?>/g, (all,src,alt) => `${all}<span style="margin-top:-5px;text-decoration: underline;text-underline-offset:2px;text-decoration-color:#d9d9d9;font-size:13px;text-align:center;display:block;">${alt}</span>`);
return html;
},
本文由作者按照 CC BY 4.0 进行授权