Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stylesheet URL does not reference path correctly #16

Open
brettcave opened this issue May 18, 2012 · 0 comments
Open

stylesheet URL does not reference path correctly #16

brettcave opened this issue May 18, 2012 · 0 comments

Comments

@brettcave
Copy link

From within a node directory, if docco-husky is run for files across sub-directories, then the reference to the style sheet is invalid if "./" is used as the prefix to the path

[node_project] $ docco-husky app.js ./routes/index.js ./test/sometest.js

The reference to docco.js from routes/index.js.html is "../../docco.css", whereas the path should be "../docco.css".

The reason for using "./" as a prefix, is that it allows the use of "find" with docco:

$ docco-husky `find ./ -type f -name '*.js'

A workaround for now is to pipe to a search & replace editor (e.g. sed / perl / awk) to strip:
$ docco-husky find ./ -type f -name '*.js' | sed -re 's/^\.\///g'

The bug can be found here, for example: resources/content.jade, line 2:

  • root_path = (root_path == "./") ? root_path : root_path.replace(/[^\/]+/g, '..')

the regex matches "./" and replaces it with "../" (i.e. from current_dir to parent_dir).

This can be resolved by changing the regex to (/[^\/.]+/g, '..') I think (i have tested in my environment, but not thoroughly).

or
.replace(/^.//g,'').replace(/[^\/]+/g, '..')

there's probably a better way to implement this with regex though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant