From edf3675f32e9bd33b5613e48d3d11bd56cdb5f0e Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Wed, 30 Mar 2022 18:38:14 +0800 Subject: [PATCH] Support linebreaks inside `a` and `img` elements * See: https://github.com/next-theme/hexo-theme-next/issues/497 --- scripts/filters/post.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/filters/post.js b/scripts/filters/post.js index 511de93..23f3aab 100644 --- a/scripts/filters/post.js +++ b/scripts/filters/post.js @@ -10,13 +10,13 @@ hexo.extend.filter.register('after_post_render', data => { const theme = hexo.theme.config; if (!theme.exturl && !theme.lazyload) return; if (theme.lazyload) { - data.content = data.content.replace(/(]*) src=/img, '$1 data-src='); + data.content = data.content.replace(/(]*)src=/ig, '$1data-src='); } if (theme.exturl) { const siteHost = parse(config.url).hostname || config.url; // External URL icon const exturlIcon = theme.exturl_icon ? '' : ''; - data.content = data.content.replace(/]* href="([^"]+)"[^>]*>([^<]+)<\/a>/img, (match, href, html) => { + data.content = data.content.replace(/]*href="([^"]+)"[^>]*>([^<]+)<\/a>/ig, (match, href, html) => { // Exit if the href attribute doesn't exists. if (!href) return match;