From 1a137826f70b64147d97ce38d8c0690d37999be2 Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Mon, 19 Dec 2022 21:40:14 +0800 Subject: [PATCH] [fix] search #211 --- scripts/generators/search.js | 40 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/scripts/generators/search.js b/scripts/generators/search.js index 5ffc1af..6b8f007 100644 --- a/scripts/generators/search.js +++ b/scripts/generators/search.js @@ -48,27 +48,27 @@ hexo.extend.generator.register('search_json_generator', function (locals) { content = content.replace(//g, '$1') // 不保留内容的标签 content = content.replace(/{%\s*(.*?)\s*%}/g, '') - // 注释 - content = content.replace(//g, '') - // ## 标题 - content = content.replace(/[#]{2,} /g, '') - // 部分HTML标签 - content = content.replace(//g, '') - content = content.replace(/
/g, '') - content = content.replace(/
/g, '') - // 图片 - content = content.replace(/\!\[(.*?)\]\((.*?)\)/g, '') - // 链接 - content = content.replace(/\[(.*?)\]\((.*?)\)/g, '$1') - // 过滤代码块 - if (cfg.codeblock == false) { - content = content.replace(/```([^`]+)```/g, '') - } - // 多个连续空格换成单个空格 - content = content.replace(/[\s]{2,} /g, ' ') - // 特殊字符 - content = content.replace(/[\r|\n]+/g, '') } + // 注释 + content = content.replace(//g, '') + // ## 标题 + content = content.replace(/[#]{2,} /g, '') + // 部分HTML标签 + content = content.replace(//g, '') + content = content.replace(/
/g, '') + content = content.replace(/
/g, '') + // 图片 + content = content.replace(/\!\[(.*?)\]\((.*?)\)/g, '') + // 链接 + content = content.replace(/\[(.*?)\]\((.*?)\)/g, '$1') + // 过滤代码块 + if (cfg.codeblock == false) { + content = content.replace(/```([^`]+)```/g, '') + } + // 多个连续空格换成单个空格 + content = content.replace(/[\s]{2,} /g, ' ') + // 特殊字符 + content = content.replace(/[\r|\n]+/g, '') temp_post.content = content.trim() } if (post.tags && post.tags.length > 0) {