datopian / flowershow

💐 Publish your obsidian digital garden or any markdown site easily and elegantly.
https://flowershow.app/
MIT License
838 stars 98 forks source link

Links to content blocks #62

Open olayway opened 2 years ago

olayway commented 2 years ago

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.

rufuspollock commented 2 years ago

@khalilcodes isn't this already supported in remark-wiki-link-plus (ie. you support [[xyz#anchor-link]]?

rufuspollock commented 2 years ago

Actually this may be tough depending on how obsidian inserts those anchors into the file. Need to research that.

blacklightpy commented 11 months ago

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.

rufuspollock commented 11 months ago

@blacklightpy how does obsidian encode the anchor link in markdown (and how does it insert the target anchor in markdown?)

blacklightpy commented 11 months ago

@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.

rufuspollock commented 11 months ago

@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 commented 11 months ago

@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-and-underscores which appear at the end of a block, because custom anchors exist too.

blacklightpy commented 11 months ago

@rufuspollock More details (I just installed Obsidian after setting up my PC)

rufuspollock commented 11 months ago

@blacklightpy thank-you this is very useful.

blacklightpy commented 9 months ago

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.