diff --git a/README.md b/README.md index 74de376..569cd06 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,13 @@ mip: > 注意:使用该方式加载样式后,将忽略 **#1 默认全部加载** 和 **#2 主动调用 mipcss 函数加载指定文件** ,因为页面已经存在 `'; + + if (/([\s\S]+?)<\/noscript>([\s\S]*?)<\/head>/.test(html)) { + html = html.replace('', styles + ''); + } + else { + html = html.replace('', styles + ''); + } + + return html; +}; + module.exports = function (hexo, config) { hexo.extend.filter.register('after_render:html', function (html) { if (!isMip(html)) { @@ -19,7 +66,10 @@ module.exports = function (hexo, config) { // 如果 标签内存在 '; - - if (/([\s\S]+?)<\/noscript>([\s\S]*?)<\/head>/.test(html)) { - html = html.replace('', content + ''); - } - else { - html = html.replace('', content + ''); - } - - return html; + return mergeStyles({ + html: html, + source: content, + cssmin: config.cssmin + }); }, 8); // 主动加载 diff --git a/test/style.js b/test/style.js index 1190c90..45eb935 100644 --- a/test/style.js +++ b/test/style.js @@ -265,10 +265,9 @@ describe('style.js', function () { expect(callback(head)).to.equal([ '', '', - '', + '', '', '', - '', '' ].join('')); }); @@ -473,6 +472,85 @@ describe('style.js', function () { }); }); + describe('multiple `', + '', + '' + ].join(''); + + expect(callback(head)).to.equal([ + '', + '', + '', + '', + '', + '' + ].join('')); + }); + + it(' has ', + '', + '', + '', + '', + '' + ].join(''); + + expect(callback(head)).to.equal([ + '', + '', + '', + '', + '', + '' + ].join('')); + }); + + it(' has ', + '', + '', + '', + '', + '' + ].join(''); + + expect(callback(head)).to.equal([ + '', + '', + '', + '', + '', + '', + '' + ].join('')); + }); + }); }); });