aigis-styleguide / aigis

CSS Styleguide Generator

Home Page:http://aigis-styleguide.github.io/aigis/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Side menu does not build properly on Windows

areologist opened this issue · comments

The path.sep value in the createTreeNode() function (within parse_tree.js) is '\' on Windows but it's '/' on POSIX systems. Delivered style guide to team on Windows machines who are unable to properly build it because the path.sep value is used to split the cpath string for building the navigation structure.

Since this is not a case of reading the file system, but only of parsing a string defined within the /* ... */ headers, is it necessary to use path.sep rather than just hard-coding a delimiter or making it configurable?

Thanks!

@geckotang, I removed path.sep in createTreeNode() and a couple other places (not for PR, just troubleshooting), and then discovered a second problem.

The regex for finding the comment blocks fails for most files on this Windows + oldish NodeJS environment.

On my Macbook this all works fine, but on the environment of the team this regex does not match the comments reliably. I have not determined the reason why.

var regex_comment = /\/\*[\s\S]?\n-{3}[^*]*\*+([^/*][^*]*\*+)*\//g;

I dropped in this quick alternative regex and it reads the comments fine.

var regex_comment = /\/\*(\*(?!\/)|[^*])*\*\//g;

But I can't say that this new regex is great and would not break other people's projects if submitted via PR. This issue needs more investigation.

PR submitted.

#109

Updating PR to fix one more issue, again, in /lib/parser/src/css.js:

var fb = comment.indexOf('\n'); returns 3 on POSIX system and 4 on legacy Windows which means that the lb - 3 on the subsequent line:

return comment.substr(fb + 1, lb - 3);

Is off by one on legacy Windows which results in random asterisks in the content depending on the whitespace near the end of the comment.

Changing it to lb - 4 works on Windows, but is then too much on OS X, where something like </a>*/ will result in </a. So the solution is lb - (fb + 1).. PR update coming.

@areologist I merged your PRs 👍