From 4be3e6e123b7d22f00d5a4d419c954bb2557cf67 Mon Sep 17 00:00:00 2001 From: Tron Date: Wed, 17 May 2023 10:35:39 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20markdown=20title=E4=BD=9C=E4=B8=BA?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=A0=87=E9=A2=98=20(#295)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 图片无title,标题不显示 图片有title,标题显示 适配语雀、思源笔记等支持markdown的平台 --- scripts/filters/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/filters/index.js b/scripts/filters/index.js index b05d95c..1c48850 100644 --- a/scripts/filters/index.js +++ b/scripts/filters/index.js @@ -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; }