Improve on-page header link resolution and default anchor handling (for footnotes, etc)#667
Improve on-page header link resolution and default anchor handling (for footnotes, etc)#667samuel-reinhardt wants to merge 4 commits intoKosmosisDire:masterfrom
Conversation
|
Updated to use better handling for heading hierarchy, and add support for same-page block links which should satisfy issue #57 |
|
@samuel-reinhardt, thanks for the cool PR! Was missing this feature too! Found a bug: blocks links with CAPITAL letters are not supported. If you click on link with capital letters browser darkens then reopens the page with scroll position on top. Update: I tried to uncheck |
|
Also when scrolled to block link it would be better to scroll not to exact block link target position but one line above. |
@d9k Can you copy and paste the markdown you're seeing this issue with for me to verify? I believe the issue is just that Obsidian header links are case insensitive, while browser-native anchor link handling is case sensitive. So if the scenario you're encountering is what I think, capital letters still work, it's just a mismatch between link and ID.
This can/should be handled via styling. The default obsidian behavior doesn't seem to do this, so I think it makes sense to leave the default behavior as-is. However I've added a class to block links to allow for easier targeting of this behavior. Ex for only block links: .blockid-target {
scroll-margin: 2ex;
}For everything: :is(*) {
scroll-margin: 2ex;
} |
|
Thanks this is great! Does something still need to be done about the case sensitivity for block links? |
Yes, it still needs to be handled. I should have time this weekend. |
|
Okay thanks! One thing I also notice is that in your test page it shows all resolved links as unresolved (they all have the .is-unresolved class). I beleive this was working previously where resolved links would be normal and unresolved links would ha ve the .is-unresolved class. It seems in your test page it is ironically the opposite where only the unresolved links are showing as resolved |
|
Finally, I also notice that the hover previews are not working for those links. This may be because they are marked as unresolved, or it may be something else. But the hover preview should, theoretically, actually show only the content being pointed to (the header section, block, footer, etc) |
|
@samuel-reinhardt, thanks for advice about
I meant not header links but block links. Something like ^my-SQL-query
.....Many lines
[[#^my-SQL-query]] |
|
@samuel-reinhardt Hi! I'm seeing this issue as well prior to any of your changes as manifested at https://lot.tas.bot - if the file is downloaded and opened, links work properly, but not when hosted with a metadata.json file present. To reproduce what I'm seeing, do a I'm unsure if this test scenario is helpful or not but my hope is I can retest after you've made your changes and they make it into a beta release. Thanks for taking another glance at this when you get a moment, I appreciate it! |
Should resolve issue #646 and some other issues with internal link resolution I was seeing (not filed issues).
My testing ground for reference: https://vectorarrow.com/experiments/test/footer-test.html