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

proposed addition for path containing filename #5

Closed
wants to merge 1 commit into from

Conversation

blefort-uo
Copy link
Contributor

@contrext : I was on the impression that I submitted this yesterday, but I might not have press the button. This fix is to add a functionality to the function relpath:fixRelativePath. Since this function is used extensively, I propose the patch in a Pull Request so you can review it.

Given path with filename relpath:fixRelativePath('concept/topicA.html', 'concept/topicB.html'), will return ../topicB.html instead of topicB.html because the function was not designed to support path with filename. The issue is not with this function, but the function relpath:analyzePathTokens which is called by relpath:fixRelativePath

I propose to add a fix to relpath:analyzePathTokens. I do not really like but I could not find a better way. The function tokenize the path, and evaluate each token. It append one ".." for each token left in the source but it does not check if the token is a filename. In the fix, the code simply check if the token contains an file extension, and if true, it does not append a ".." in that case. See line 767 to 775

An other option might be to duplicate the function

@blefort
Copy link
Contributor

blefort commented Feb 18, 2015

This is to fix dita4publishers/org.dita4publishers.html5#34

@blefort
Copy link
Contributor

blefort commented Feb 19, 2015

I see another issue with this code, that we might consider. The code won't work with uri containg hash

I am thinking to chunked content, when we have the chunked entry in the navigation, only the hash should render in the navigation when the chunked page is the current one.

This would allow to make ScrollSpy navigation work (the entry in the navigation highlight when the user scroll down)

@drmacro
Copy link
Contributor

drmacro commented Feb 19, 2015

The problem is that it's impossible to know, in XSLT, if a path is a filename or not--the presence of an extension is not reliable. For example, the directory "org.dita4publishers.epub" would match a check for an extension.

The function is documented as only operating on directories.

If you know that what you have includes the filename, then you can use getParent() to strip off the filename and then do the relative path calculation.

@blefort
Copy link
Contributor

blefort commented Feb 19, 2015

Ok, I get it, will do as you just explained

@blefort blefort closed this Feb 19, 2015
@blefort blefort deleted the relativePathForFile branch February 19, 2015 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants