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

Bug: Link to headings not working #202

Closed
pbogre opened this issue Jun 23, 2024 · 4 comments
Closed

Bug: Link to headings not working #202

pbogre opened this issue Jun 23, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@pbogre
Copy link
Contributor

pbogre commented Jun 23, 2024

Headings still have their id attribute applied correctly via the customHTMLRenderer from baseOptions.js, however linking to these headings is not as simple after the recent update introducing support for running flatnotes in a subpath.

Before, I was able to link to a heading in the same document with this code:

[Link to Heading](#heading-name)

However after the update this redirects me to http://example.com:8080/#heading-name, instead of the old funtional http://example.com:8080/note/ExampleNote/#heading-name. If I used instead something like:

[Link to Heading](/note/ExampleNote#heading-name)

Then it would work correctly, but it's quite ugly and requires a lot of repetition. I also tried using WikiLinks like so:

[[ExampleNote#heading-name]]

But this redirects me to http://example.com:8080/note/ExampleNote%23heading-name.

A fix could be to change the behavior of links when they start with a # character, so for instance [Link to Heading](#heading-name) always prepends the note's path to the redirecting URL. Otherwise it could be convenient to stop converting characters into URL-compatible characters when using WikiLinks, like in the example above where # becomes %23. This could be seen as an extension of WikiLinks, allowing you to not only link to another note but also a specific section of that note.

I'm not sure how these changes would fare with an application running on a subpath.

@dullage dullage added the bug Something isn't working label Jun 26, 2024
@dullage
Copy link
Owner

dullage commented Jun 26, 2024

Ah. I made sure to cover all relative paths in the application but hadn't considered that there might be relative paths in the content!

I'll take a look to see if I can intercept the rendering of hyperlinks and use Vue Router to set the href value to an absolute path (which would take path prefixes into account).

@dullage
Copy link
Owner

dullage commented Jun 27, 2024

@pbogre - The develop branch now has a resolution for this. [Link to Heading](#heading-name) should now resolve as expected. I've pushed a build to Docker Hub, so please give the :develop tag a go if you can.

@pbogre
Copy link
Contributor Author

pbogre commented Jun 27, 2024

Thanks for looking into this! I'll check out the develop branch as soon as I can.

@pbogre
Copy link
Contributor Author

pbogre commented Jun 28, 2024

Just tested it, can confirm it's working! Thanks again.

@dullage dullage closed this as completed Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants