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

[SUPPORT] Cannot link to certain heading #3181

Closed
DutchPete opened this issue Dec 21, 2024 · 24 comments
Closed

[SUPPORT] Cannot link to certain heading #3181

DutchPete opened this issue Dec 21, 2024 · 24 comments

Comments

@DutchPete
Copy link

Question

I have a note with 11 headings, numbered from 1 to 11, though there are subheadings too.
In the outline pane all headings are shown.
However, when I want to link to heading 10 or 11 from another note, the last heading shown in the dropdown list when I press CTRL+Shift+L is heading 9.2.1.
Even when I write out the syntax manually, the link does not work.

Output from the debug section in the settings dialog

Expand

Relevant log output in the Log panel

You have to enable the Log panel in the Windows menu!
I did but I don't see it.

Alternatively you can also turn on a log file in the settings.
I did. I it a very big file, so here is what I think may be relevant:

[Dec 21 15:05:43] [debug]: fileUrlInCurrentNoteFolderToRelativePath  - 'path':  "/home/user1/MEGA/Obsidian/Germanys-war-highlights.md"
[Dec 21 15:05:43] [debug]: fileUrlInCurrentNoteFolderToRelativePath  - 'canonicalFilePath':  "/home/user1/MEGA/Obsidian/Germanys-war-highlights.md"
Expand
@pbek
Copy link
Owner

pbek commented Dec 21, 2024

Can you please provide an example note and some markdown where you linked to it? I can't really grasp your issue without more context.

@DutchPete
Copy link
Author

Here is the actual file I am talking about.
Germanys-war-highlights.md

Download it, then from any note try to link to heading 10 or 11.

@pbek
Copy link
Owner

pbek commented Dec 22, 2024

I guess you are talking about the 10th or 11th heading, not a heading 10 or 11, right? Those are all heading 1.
No heading 1 is showing up in the list, because you are not supposed to have multiple of them (according to HTML spec).

@DutchPete
Copy link
Author

Yes, I am talking about 10th and 11th heading.

you are not supposed to have multiple of them (according to HTML spec)

I don't understand:

  1. if you are not supposed to have multiple heading 1, why then does QON show 9 of them?
  2. HTML spec: I thought QON follows Markdown specs?

@pbek
Copy link
Owner

pbek commented Dec 22, 2024

if you are not supposed to have multiple heading 1, why then does QON show 9 of them?

Look closer, none are shown, it shows heading 2 and 3.

image

Only to make sure we are talking from the same thing: https://www.w3schools.com/html/html_headings.asp

HTML spec: I thought QON follows Markdown specs?

It's not about the Markdown specs, it's about that you are not supposed to have more than one heading 1 in a document.
The h1 should succinctly represent the content on that "page". You can have as many h2, h3 and so on as you like.

@DutchPete
Copy link
Author

DutchPete commented Dec 22, 2024

Gotcha. That means all H1 links in ALL my notes that I have composed in other apps and have many H1 headings have become useless.

BTW, I was using the outline as a guide:

image

@pbek
Copy link
Owner

pbek commented Dec 22, 2024

That meansall H1 links in ALL my notes that I have composed in other apps and have many H1 headings have become useless.

Just do a regular expression replace of ^# with ## and shift all headings or use the script Headline depth buttons.

@DutchPete
Copy link
Author

Phew, nothing is lost, as it were.
It will be a useful exercise because I remember someone once mentioning it over at the Obsidian forum, but since Obsidian can handle multiple H1 headings and linking to them, I ignored the comment. I think Logseq also has the same limitation of only 1 H1 per note.

BTW, what is the meaning of the ^ in ^#?

@pbek
Copy link
Owner

pbek commented Dec 22, 2024

In regular expressions, a ^ signals the start of a line.

I looked at the link dialog code and the code of the linking (that also needs to support that) and it would be possible to support heading 1, but like previously only those headings starting with '#', so still no ======= and ---------- (see https://www.qownnotes.org/getting-started/markdown.html). Those would be hard to parse.

@pbek
Copy link
Owner

pbek commented Dec 22, 2024

Phew, nothing is lost, as it were.

With plain text files, nothing is lost most of the time... You can search/replace a lot. You could even ask your ChatGPT to manipulate the text for you. 😉

pbek added a commit that referenced this issue Dec 22, 2024
Signed-off-by: Patrizio Bekerle <[email protected]>
@pbek
Copy link
Owner

pbek commented Dec 22, 2024

24.12.5

  • Both note links and the link dialog are now supporting also heading 1, not only
    heading 2 and up, as long # headings are used (for #3181)

@pbek pbek added this to the 24.12.5 milestone Dec 22, 2024
@pbek
Copy link
Owner

pbek commented Dec 22, 2024

There now is a new release, could you please test it and report if it works for you?

@pbek pbek added Importance: Low Type: Improvement improves existing functionality and removed Type: Support labels Dec 22, 2024
@DutchPete
Copy link
Author

I am using the Flatpak version, as that is what there is in my system package manager. I checked on your Flathub page but you have not pushed this version to Flathub yet.

BTW, in your opinion, is the Flatpak version OK to use or would you recommend something else?

@pbek
Copy link
Owner

pbek commented Dec 22, 2024

The flathub package was just built. Yes, you can use it.

@DutchPete
Copy link
Author

Yes, that works fine. Many thanks for amending the app this way.

@pbek
Copy link
Owner

pbek commented Feb 1, 2025

I think I need to take that feature back, it causes comments in code blocks also to be detected as headings!

@DutchPete
Copy link
Author

So, why does an app like Obsidian not have that problem?

@pbek
Copy link
Owner

pbek commented Feb 1, 2025

Was that a serious question or a troll question?

@DutchPete
Copy link
Author

I am not in the habit of trolling, so yes, it is a serious question.

Remember, I am the one who asked for the feature, you are the one who implemented it, now you are the one who is retracting it.

I am surprised you did not realize comments in code blocks would be detected as headings. Code blocks can also be used in Obsidian, yet H1 heading links don't cause that problem, hence my question.

If, however, the question seems stupid to you, don't bother to answer.

@pbek
Copy link
Owner

pbek commented Feb 1, 2025

It's a different application with a different code base.

pbek added a commit that referenced this issue Feb 2, 2025
…t to get list of headings

Signed-off-by: Patrizio Bekerle <[email protected]>
pbek added a commit that referenced this issue Feb 2, 2025
…t to jump to headings

Signed-off-by: Patrizio Bekerle <[email protected]>
pbek added a commit that referenced this issue Feb 2, 2025
Signed-off-by: Patrizio Bekerle <[email protected]>
pbek added a commit that referenced this issue Feb 2, 2025
@pbek
Copy link
Owner

pbek commented Feb 2, 2025

25.2.1

  • The heading detection in the link dialog and when jumping to the heading in a
    note link was re-implemented and now uses the highlighting states of the note
    editor component (for #3181)
    • Now also the "underline-ish style" headings are recognized and there are no
      issues with comments in code blocks that are detected as headings anymore

There now is a new release, could you please test it and report if it works for you?

@DutchPete
Copy link
Author

Yes, that works fine, Patrizio. Thank you.

@pbek
Copy link
Owner

pbek commented Feb 4, 2025

Great, thank you for testing!

@DutchPete
Copy link
Author

You're welcome, you deserve it 😀

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

No branches or pull requests

2 participants