Open olayway opened 2 years ago
@khalilcodes isn't this already supported in remark-wiki-link-plus (ie. you support [[xyz#anchor-link]]
?
Actually this may be tough depending on how obsidian inserts those anchors into the file. Need to research that.
We can actually use custom anchors. Basically it's just some random anchors, you just have to look into the mentioned page and find the block containing the anchor.
@blacklightpy how does obsidian encode the anchor link in markdown (and how does it insert the target anchor in markdown?)
@rufuspollock So basically if we use the menu to create an anchor to a block, it will assign a random ID (6 digit alphanumeric) to that block by ending the block with ^ID
.
I can refer to it by [[Page To Link#^ID]].
So I can manually name blocks by ending them with ^my-anchor
and I can refer to them by typing [[Page To Link#^my-anchor]].
Spaces are not allowed in anchor names.
I also think anchors only have to be unique per page. So it's not stored in a database, but rather it's like simple HTML anchors.
Edit: corrected ^Id to #^ID inside Wikilink syntax.
@blacklightpy thanks for the clear write-up.
So basically to implement you need to search for regex pattern ^six-digit-alphanumeric
and then convert that to html anchors in the processing.
@blacklightpy thanks for the clear write-up.
So basically to implement you need to search for regex pattern
^six-digit-alphanumeric
and then convert that to html anchors in the processing.
@rufuspollock No, you should search for ^any-length-alphanumeric-with-hypens
which appear at the end of a block, because custom anchors exist too.-and-underscores
@rufuspollock More details (I just installed Obsidian after setting up my PC)
done.
, the anchor should be done. ^anchor
, not done^anchor
. Although I don't think this will make an effective difference (exceptions being cases where the block ends with something like x^2
)@blacklightpy thank-you this is very useful.
One more correction.. it's not [[Page to Link^anchor]], it is [[Page to Link#^anchor]].
Without the #, it will try to look for a page named "Page to Link^anchor".
# is for heading anchors and ^ is for blocks. So basically a block ID is implemented as a special type of heading anchor.
Links to a specific block (paragraph) within a given page, e.g.
[[roadmap#^dcf64c]]
.See obsidian docs for reference.
Design
UPDATE 2023-12-12 from https://github.com/datopian/flowershow/issues/62#issuecomment-1843646839
To support these probably want a remark plugin or simple regex pattern match that search for
^six-digit-alphanumeric
and then converts that to html anchors in the output.