[feat] markdown title作为图片标题 (#295)

图片无title,标题不显示
图片有title,标题显示
适配语雀、思源笔记等支持markdown的平台
This commit is contained in:
Tron 2023-05-17 10:35:39 +08:00 committed by GitHub
parent f4c12ad164
commit 4be3e6e123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -5,7 +5,10 @@ hexo.extend.filter.register('after_render:html', require('./lib/img_onerror').pr
function change_image(data) {
if (this.theme.config.tag_plugins.image.parse_markdown) {
data.content = data.content.replace(/!\[([^\]]*)]\(([^(]+)\)/g, '{% image $2 $1 %}');
data.content = data.content.replace(
/!\[(.*?)\]\((.*?)\s*(?:"(.*?)")?\)/g,
'{% image $2 $3 %}'
);
}
return data;
}