hexojs / hexo-renderer-less

Less renderer for Hexo.
https://hexo.io/
MIT License
14 stars 10 forks source link

Fails on `hexo generate` #1

Closed thom4parisot closed 10 years ago

thom4parisot commented 10 years ago

Hello,

for some reason the parser is failing on a file which is not supposed to be parsed by the less renderer.

$ ./node_modules/.bin/hexo generate
[info] Files loaded in 4.739s

/path/to/oncletom.io/node_modules/hexo-renderer-less/node_modules/less/lib/less/parser.js:604
                        throw new(LessError)(e, env);
                              ^
HexoError: Process failed: _posts/2014/present.md

I ran the command with the --debug flag and saw the html file was nonetheless properly generated.

So I am wondering why a markdown file is handled by the less parser. I am using hexo: 2.5.3 with node 0.10.26.

The markdown file is https://github.com/oncletom/oncletom.io/blob/master/source/_posts/2014/present.md

thom4parisot commented 10 years ago

Oh investigating a bit more, it seems the renderer tries to render all my less files, even the ones which are only loaded through @import.

I guess the file is put in the store and rendered in all case.

How can I prevent this file to be rendered?

tommy351 commented 10 years ago

Prefixing file name with _ can prevent files from being processed.

thom4parisot commented 10 years ago

:thumbsup: thanks!

philippkeller commented 10 years ago

I think the error occurs if less is reading a less file which references a variable via @ which is not yet defined.

The solution is to prepend all less files with _ except the main less file. Otherwise less is trying to read a less file whose variables are not yet defined.

Why less is trying to read the markdown files still seems like a bug to me.