Closed lakokkonen closed 1 year ago
@lakokkonen I can't reproduce this on macOS. The toggler works fine there regardless of hierarchy.
Are you running into this problem on Windows?
@infotexture Yes, I'm using Windows and local files.
It seems like this issue stems from the Windows file path naming which uses backslashes.
@lakokkonen - I think the following regex simplifies your fix and continues to work on Linux - could you check
<xsl:value-of select="replace(replace($FILEDIR, '\\', '/') ,'[^/]+','..')"/>
see #142
@jason-fox yes, now it's working on Windows.
By the way: This same issue also affects the lunr plugin's path to the JS file. Currently the search is not working on Windows if a topic is located in a subfolder. The new regex fixes this, too.
Using the latest dev version of the plugin.
If a topic is located in a subfolder more than one level deep from the output directory, the dark mode toggler doesn't work on the HTML page.
It looks like the path to the .js file is always ../js/dark-mode-toggler.js, and of course that only works for pages that are located one folder deep. I believe the issue is in the relpath variable, but that's where my XSLT skills end in this case.
EDIT:
Actually now I got it working by changing the regex in the replace function:
But as a result the file path contains both forward and backslashes. Seems to work, however, both on local files and via an http server.
EDIT 2:
I was able to switch the backslashes to forward ones with this monstrosity: