Coder Social home page Coder Social logo

Comments (5)

t3hp0rP avatar t3hp0rP commented on July 20, 2024 1

初步想法是html-minifier试图把代码中单独的< 比如

<?php

or连续的<< 比如

<strong><</strong>

解析成tree,所以他就会认为尖括号没有闭合导致报错。。。。

from hexo-neat.

t3hp0rP avatar t3hp0rP commented on July 20, 2024

ignoreCustomFragments能大概解决这个问题 但是又会出现新问题,比如出现奇奇怪怪的error信息

Parse Error: <	yab1l992mg1	a	yab1l992mg2		yab1l992mg3	h	yab1l992mg4	r	yab1l992mg5	e	yab1l992mg6	f	yab1l992mg7	=	yab1l992mg8	"	yab1l992mg9	yab1l992mg10	2	yab1l992mg11	0	yab1l992mg12	1	yab1l992mg13	7	yab1l992mg14	yab1l992mg15	1	yab1l992mg16	0	yab1l992mg17	/	yab1l992mg18	2	yab1l992mg19	yab1l992mg20	/	yab1l992mg21	W	yab1l992mg22	e	yab1l992mg23	b	yab1l992mg24	狗	yab1l992mg25	要	yab1l992mg26	懂	yab1l992mg27	的	yab1l992mg28	C	yab1l992mg29	B	yab1l992mg30	C	yab1l992mg31	翻	yab1l992mg32	转	yab1l992mg33	字	yab1l992mg34	节	yab1l992mg35	攻	yab1l992mg36	击	yab1l992mg37	-	yab1l992mg38	yab1l992mg39	l	yab1l992mg40	i	yab1l992mg41	p	yab1l992mg42	p	yab1l992mg43	yab1l992mg44	d	yab1l992mg45	-	yab1l992mg46	C	yab1l992mg47	i	yab1l992mg48	yab1l992mg49	h	yab1l992mg50	e	yab1l992mg51	r	yab1l992mg52	t	yab1l992mg53	yab1l992mg54	x	yab1l992mg55	t	yab1l992mg56	-	yab1l992mg57	B	yab1l992mg58	yab1l992mg59	t	yab1l992mg60	s	yab1l992mg61	/	yab1l992mg62	"	yab1l992mg63	yab1l992mg64	c	yab1l992mg65	l	yab1l992mg66	a	yab1l992mg67	s	yab1l992mg68	yab1l992mg69	=	yab1l992mg70	"	yab1l992mg71	a	yab1l992mg72	r	yab1l992mg73	yab1l992mg74	i	yab1l992mg75	c	yab1l992mg76	l	yab1l992mg77	e	yab1l992mg78	yab1l992mg79	d	yab1l992mg80	a	yab1l992mg81	t	yab1l992mg82	e	yab1l992mg83	yab1l992mg84	>	yab1l992mg85		yab1l992mg86	<	yab1l992mg87	t	yab1l992mg88	yab1l992mg89	m	yab1l992mg90	e	yab1l992mg91		yab1l992mg92	d	yab1l992mg93	yab1l992mg94	t	yab1l992mg95	e	yab1l992mg96	t	yab1l992mg97	i	yab1l992mg98	yab1l992mg99	e	yab1l992mg100	=	yab1l992mg101	"	yab1l992mg102	2	yab1l992mg103	yab1l992mg104	1	yab1l992mg105	7	yab1l992mg106	-	yab1l992mg107	1	yab1l992mg108	yab1l992mg109	-	yab1l992mg110	2	yab1l992mg111	4	yab1l992mg112	T	yab1l992mg113	yab1l992mg114	5	yab1l992mg115	:	yab1l992mg116	4	yab1l992mg117	4	yab1l992mg118	yab1l992mg119	0	yab1l992mg120	0	yab1l992mg121	.	yab1l992mg122	0	yab1l992mg123	yab1l992mg124	0	yab1l992mg125	Z	yab1l992mg126	"	yab1l992mg127		yab1l992mg128	yab1l992mg129	t	yab1l992mg130	e	yab1l992mg131	m	yab1l992mg132	p	yab1l992mg133	yab1l992mg134	o	yab1l992mg135	p	yab1l992mg136	=	yab1l992mg137	"	yab1l992mg138	yab1l992mg139	a	yab1l992mg140	t	yab1l992mg141	e	yab1l992mg142	P	yab1l992mg143	yab1l992mg144	b	yab1l992mg145	l	yab1l992mg146	i	yab1l992mg147	s	yab1l992mg148	yab1l992mg149	e	yab1l992mg150	d	yab1l992mg151	"	yab1l992mg152	>	yab1l992mg153	yab1l992mg154	0	yab1l992mg155	1	yab1l992mg156	7	yab1l992mg157	-	yab1l992mg158	yab1l992mg159	0	yab1l992mg160	-	yab1l992mg161	2	yab1l992mg162	4	yab1l992mg163	yab1l992mg164	/	yab1l992mg165	t	yab1l992mg166	i	yab1l992mg167	m	yab1l992mg168	yab1l992mg169	>	yab1l992mg170		yab1l992mg171	<	yab1l992mg172	/	yab1l992mg173	yab1l992mg174	>	yab1l992mg175	
    at new HTMLParser (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/html-minifier/src/htmlparser.js:235:13)
    at minify (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/html-minifier/src/htmlminifier.js:945:3)
    at exports.minify (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/html-minifier/src/htmlminifier.js:1294:10)
    at Hexo.logic_html (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo-neat/lib/filter.js:28:18)
    at Filter.execSync (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/extend/filter.js:74:28)
    at Hexo.execFilterSync (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/hexo/index.js:432:29)
    at Theme._View.View._compiledSync (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/theme/view.js:120:18)
    at Theme._View.View.View.renderSync (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/theme/view.js:48:23)
    at Object.partial (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/plugins/helper/partial.js:34:15)
    at eval (eval at compile (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/ejs/lib/ejs.js:633:12), <anonymous>:20:17)
    at returnedFn (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/ejs/lib/ejs.js:668:17)
    at Theme._View.View._compiledSync (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/theme/view.js:119:22)
    at Theme._View.View.View.renderSync (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/theme/view.js:48:23)
    at Object.partial (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/plugins/helper/partial.js:34:15)
    at eval (eval at compile (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/ejs/lib/ejs.js:633:12), <anonymous>:15:17)
    at Model._Query.Query.Query.forEach (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/warehouse/lib/query.js:42:5)
    at eval (eval at compile (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/ejs/lib/ejs.js:633:12), <anonymous>:12:19)
    at returnedFn (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/ejs/lib/ejs.js:668:17)
    at Theme._View.View._compiledSync (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/theme/view.js:119:22)
    at Theme._View.View.View.renderSync (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/theme/view.js:48:23)
    at Object.partial (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/plugins/helper/partial.js:34:15)
    at eval (eval at compile (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/ejs/lib/ejs.js:633:12), <anonymous>:9:17)

from hexo-neat.

porterpan avatar porterpan commented on July 20, 2024

错误现象

  • 遇到尖括号就报错啥的
FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Error: Parse Error: <--> C2: Cool label</p>
<ul>
<li>具体使用<a href="https://github.com/knsv/mermaid">帮助文档请移步github</a></li>
</ul>

解决办法

查找这个文件node_modules/hexo-neat/index.js

  • [ x ] 我的文件路径为:
/GitHub_Projects/porterpan.github.io/node_modules/hexo-neat/index.js
  • [ x ] 改写里面的代码:
            ignoreCustomComments: [/^\s*more/],
	///<[^>]*>/去除所有的标签
	    ignoreCustomFragments: [/<[^>]*>/,/<img[^>]*>/],

ignoreCustomFragments: [/<[^>]>/,/<img[^>]>/],是新加的。忽略尖括号和图像链接

  • 改变的整个代码
/* global hexo */
var assign = require('object-assign');

//module.exports = function (hexo) {
    if (true === hexo.config.neat_enable) {
        // HTML minifier
        hexo.config.neat_html = assign({
            enable: true,
            exclude: [],
            ignoreCustomComments: [/^\s*more/],
	///<[^>]*>/去除所有的标签
	    ignoreCustomFragments: [/<[^>]*>/,/<img[^>]*>/],
            removeComments: true,
            removeCommentsFromCDATA: true,
            collapseWhitespace: true,
            collapseBooleanAttributes: true,
            removeEmptyAttributes: true,
            minifyJS: true,
            minifyCSS: true,
        }, hexo.config.neat_html);

        // Css minifier
        hexo.config.neat_css = assign({
            enable: true,
            exclude: ['*.min.css']
        }, hexo.config.neat_css);

        // Js minifier
        hexo.config.neat_js = assign({
            enable: true,
            mangle: true,
            output: {},
            compress: {},
            exclude: ['*.min.js']
        }, hexo.config.neat_js, {
                fromString: true
            });


        var filter = require('./lib/filter');
        hexo.extend.filter.register('after_render:html', filter.logic_html);
        hexo.extend.filter.register('after_render:css', filter.logic_css);
        hexo.extend.filter.register('after_render:js', filter.logic_js);
    }
//}

附录

常见的正则表达式及注释

protected void Page_Load(object sender, EventArgs e)
  {
  //string regexstr = @"<[^>]*>"; //去除所有的标签
  //@"<script[^>]*?>.*?</script >" //去除所有脚本,中间部分也删除
  // string regexstr = @"<img[^>]*>"; //去除图片的正则
  // string regexstr = @"<(?!br).*?>"; //去除所有标签,只剩br
  // string regexstr = @"<table[^>]*?>.*?</table>"; //去除table里面的所有内容
  string regexstr = @"<(?!img|br|p|/p).*?>"; //去除所有标签,只剩img,br,p
  str = Regex.Replace(str, regexstr, string.Empty, RegexOptions.IgnoreCase);
  }

from hexo-neat.

porterpan avatar porterpan commented on July 20, 2024

ignoreCustomFragments能大概解决这个问题 但是又会出现新问题,比如出现奇奇怪怪的error信息

Parse Error: <	yab1l992mg1	a	yab1l992mg2		yab1l992mg3	h	yab1l992mg4	r	yab1l992mg5	e	yab1l992mg6	f	yab1l992mg7	=	yab1l992mg8	"	yab1l992mg9	yab1l992mg10	2	yab1l992mg11	0	yab1l992mg12	1	yab1l992mg13	7	yab1l992mg14	yab1l992mg15	1	yab1l992mg16	0	yab1l992mg17	/	yab1l992mg18	2	yab1l992mg19	yab1l992mg20	/	yab1l992mg21	W	yab1l992mg22	e	yab1l992mg23	b	yab1l992mg24	狗	yab1l992mg25	要	yab1l992mg26	懂	yab1l992mg27	的	yab1l992mg28	C	yab1l992mg29	B	yab1l992mg30	C	yab1l992mg31	翻	yab1l992mg32	转	yab1l992mg33	字	yab1l992mg34	节	yab1l992mg35	攻	yab1l992mg36	击	yab1l992mg37	-	yab1l992mg38	yab1l992mg39	l	yab1l992mg40	i	yab1l992mg41	p	yab1l992mg42	p	yab1l992mg43	yab1l992mg44	d	yab1l992mg45	-	yab1l992mg46	C	yab1l992mg47	i	yab1l992mg48	yab1l992mg49	h	yab1l992mg50	e	yab1l992mg51	r	yab1l992mg52	t	yab1l992mg53	yab1l992mg54	x	yab1l992mg55	t	yab1l992mg56	-	yab1l992mg57	B	yab1l992mg58	yab1l992mg59	t	yab1l992mg60	s	yab1l992mg61	/	yab1l992mg62	"	yab1l992mg63	yab1l992mg64	c	yab1l992mg65	l	yab1l992mg66	a	yab1l992mg67	s	yab1l992mg68	yab1l992mg69	=	yab1l992mg70	"	yab1l992mg71	a	yab1l992mg72	r	yab1l992mg73	yab1l992mg74	i	yab1l992mg75	c	yab1l992mg76	l	yab1l992mg77	e	yab1l992mg78	yab1l992mg79	d	yab1l992mg80	a	yab1l992mg81	t	yab1l992mg82	e	yab1l992mg83	yab1l992mg84	>	yab1l992mg85		yab1l992mg86	<	yab1l992mg87	t	yab1l992mg88	yab1l992mg89	m	yab1l992mg90	e	yab1l992mg91		yab1l992mg92	d	yab1l992mg93	yab1l992mg94	t	yab1l992mg95	e	yab1l992mg96	t	yab1l992mg97	i	yab1l992mg98	yab1l992mg99	e	yab1l992mg100	=	yab1l992mg101	"	yab1l992mg102	2	yab1l992mg103	yab1l992mg104	1	yab1l992mg105	7	yab1l992mg106	-	yab1l992mg107	1	yab1l992mg108	yab1l992mg109	-	yab1l992mg110	2	yab1l992mg111	4	yab1l992mg112	T	yab1l992mg113	yab1l992mg114	5	yab1l992mg115	:	yab1l992mg116	4	yab1l992mg117	4	yab1l992mg118	yab1l992mg119	0	yab1l992mg120	0	yab1l992mg121	.	yab1l992mg122	0	yab1l992mg123	yab1l992mg124	0	yab1l992mg125	Z	yab1l992mg126	"	yab1l992mg127		yab1l992mg128	yab1l992mg129	t	yab1l992mg130	e	yab1l992mg131	m	yab1l992mg132	p	yab1l992mg133	yab1l992mg134	o	yab1l992mg135	p	yab1l992mg136	=	yab1l992mg137	"	yab1l992mg138	yab1l992mg139	a	yab1l992mg140	t	yab1l992mg141	e	yab1l992mg142	P	yab1l992mg143	yab1l992mg144	b	yab1l992mg145	l	yab1l992mg146	i	yab1l992mg147	s	yab1l992mg148	yab1l992mg149	e	yab1l992mg150	d	yab1l992mg151	"	yab1l992mg152	>	yab1l992mg153	yab1l992mg154	0	yab1l992mg155	1	yab1l992mg156	7	yab1l992mg157	-	yab1l992mg158	yab1l992mg159	0	yab1l992mg160	-	yab1l992mg161	2	yab1l992mg162	4	yab1l992mg163	yab1l992mg164	/	yab1l992mg165	t	yab1l992mg166	i	yab1l992mg167	m	yab1l992mg168	yab1l992mg169	>	yab1l992mg170		yab1l992mg171	<	yab1l992mg172	/	yab1l992mg173	yab1l992mg174	>	yab1l992mg175	
    at new HTMLParser (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/html-minifier/src/htmlparser.js:235:13)
    at minify (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/html-minifier/src/htmlminifier.js:945:3)
    at exports.minify (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/html-minifier/src/htmlminifier.js:1294:10)
    at Hexo.logic_html (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo-neat/lib/filter.js:28:18)
    at Filter.execSync (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/extend/filter.js:74:28)
    at Hexo.execFilterSync (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/hexo/index.js:432:29)
    at Theme._View.View._compiledSync (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/theme/view.js:120:18)
    at Theme._View.View.View.renderSync (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/theme/view.js:48:23)
    at Object.partial (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/plugins/helper/partial.js:34:15)
    at eval (eval at compile (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/ejs/lib/ejs.js:633:12), <anonymous>:20:17)
    at returnedFn (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/ejs/lib/ejs.js:668:17)
    at Theme._View.View._compiledSync (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/theme/view.js:119:22)
    at Theme._View.View.View.renderSync (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/theme/view.js:48:23)
    at Object.partial (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/plugins/helper/partial.js:34:15)
    at eval (eval at compile (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/ejs/lib/ejs.js:633:12), <anonymous>:15:17)
    at Model._Query.Query.Query.forEach (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/warehouse/lib/query.js:42:5)
    at eval (eval at compile (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/ejs/lib/ejs.js:633:12), <anonymous>:12:19)
    at returnedFn (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/ejs/lib/ejs.js:668:17)
    at Theme._View.View._compiledSync (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/theme/view.js:119:22)
    at Theme._View.View.View.renderSync (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/theme/view.js:48:23)
    at Object.partial (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/hexo/lib/plugins/helper/partial.js:34:15)
    at eval (eval at compile (/Users/pr0ph3t/Desktop/blog/hexo/node_modules/ejs/lib/ejs.js:633:12), <anonymous>:9:17)

是不是还是你的左尖括号的错呀,可以来个正则化表达式,忽略所有尖括号试试

from hexo-neat.

t3hp0rP avatar t3hp0rP commented on July 20, 2024

感谢回答
最后是用正则把所有尖括号替换成字符实体后能解决

from hexo-neat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.