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

Intuitive linking between and within pages (e.g. headers) using file and header names #1228

Open
Lumiukko opened this issue Apr 26, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@Lumiukko
Copy link

It is very tedious to create a wiki by hand and link all the pages manually. I currently have an automated process generating markdown files, which use links to each other and to headers within those files using the formatting [Linktext](PageName#SectionHeaderToLink). This works perfectly fine in most tools using markdown natively, such as Obsidian. However, it appears in collectives there is no way of linking to a section header or linking to a file with the relative path.

I would like to be able to link to section headers of files in the same folder, or possibly in subfolders without having to manually create those links. The filename and section name should be enough information to identify the link targets.

There is no good alternative, since the links are plenty in those automatically generated files. Curating them manually is not an option.

I have seen similar feature requests, but nothing that matches exactly to this issue, if I missed it, feel free to link it.

Note that for the aforementioned link format to work, even in Obsidian, we need to replace certain characters with their URL encoding equivalent, while some others are simply replaced by a space URL encoding character (a colon becomes a %20), I am unsure if this is standard behavior or a specific choice of Obsidian.

@Lumiukko Lumiukko added the enhancement New feature or request label Apr 26, 2024
@Lumiukko
Copy link
Author

Some additional notes after fiddling around a little and reading this: https://help.nextcloud.com/t/relative-links-to-other-md-documents/156874/7

Apparently relative links are possible (since version 29) under certain circumstanes.

First of all, it still does not appear to work with Readme.md files. Then, the section headers (generated by using h1 for instance), are being formatted like h-section-title, where spaces are replaces by -, easy enough.

Here is where the weird stuff starts: If you use , in the section header, the anchor becomes undefined. If the header is something like Foo (Bar), the parentheses are being ignored and it becomes h-foo-bar. If you remove the space before the opening parenthesis Foo(Bar), it again becomes undefined.

So perhaps this issue has an easy fix of having a more reliably encoding for section headers, allowing for special characters, which should be described in the documentation.

@Lumiukko Lumiukko reopened this May 13, 2024
@Lumiukko
Copy link
Author

More info, I hope this is okay providing as much as I can find out.

At the moment I created some sort of encoding function that takes in the section title and spits out the header anchor name/id, so I can actually link to those sections.

However, when navigating to the collective page, all section headers are initially #undefined. After a refresh of the page they suddenly are all available, such as #h-section-title-1. Weirdly enough, links to that anchor do not jump to that specific heading.

I am really flabbergasted about this behavior and hope somebody could have a look at it, or at least try to reproduce. A solution would be most welcome, of course :)

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

No branches or pull requests

1 participant