datopian / flowershow

πŸ’ Publish your obsidian digital garden or any markdown site easily and elegantly.
https://flowershow.app/
MIT License
837 stars 98 forks source link

Callouts support #60

Closed olayway closed 2 years ago

olayway commented 2 years ago

We would follow Obsidian style as listed on here https://help.obsidian.md/How+to/Use+callouts

> [!INFO]
> Here's a callout block.
> It supports **markdown** and [[Internal link|wikilinks]].

Acceptance

repo: https://github.com/flowershow/remark-callouts npm: https://www.npmjs.com/package/remark-callouts

Screenshots

Tasks

Notes

rufuspollock commented 2 years ago

things i've found from a quick google:

khalilcodes commented 2 years ago

@rufuspollock

https://github.com/Nevenall/remark-containers - a bit similar in functionality though using ::: for fencing blocks

This was the closest one I had found.

I'd consider creating a new flowershow/remark-callouts repo and modifying above or https://github.com/elviswolcott/remark-admonitions as per our needs similar to what we did in remark-wiki-links-plus

rufuspollock commented 2 years ago

@khalilcodes ok - have you examined the code - what parts would be useful exactly?

khalilcodes commented 2 years ago

@rufuspollock

Browsing through remark-containers and even modifying it a bit, I could see the tokenizer handles the ":::" (or ">" in our case) found on new lines by splitting them and then transforming the nodes. Also, remark-admonitions has a similar approach including an object with a list of types (ie., note, tip, warning, etc) with their relevant properties (class, svg, etc).

The approach here I'm thinking is to see how extensively can we modify their existing code to suit our needs ?

rufuspollock commented 2 years ago

@khalilcodes sounds good. are you asking me a question at the end or a question to yourself?

khalilcodes commented 2 years ago

@rufuspollock πŸ˜„ Just validating if the approach is right.

khalilcodes commented 2 years ago

@olayway @rufuspollock

Current progress on callouts remark plugin ...

Some issues and enhancements to be addressed.

Screen Shot 2022-09-23 at 2 25 09 PM Screen Shot 2022-09-23 at 2 25 23 PM
rufuspollock commented 2 years ago

@khalilcodes imo headings in blockquotes being linked is not the end of the world (though imperfect - we can live for now and revisit - e.g. open an issue to remind ourselves of this and close this one).

khalilcodes commented 2 years ago

@rufuspollock the headings was resolved on Monday and the npm package has been published and ready to go.

repo: https://github.com/flowershow/remark-callouts npm: https://www.npmjs.com/package/remark-callouts

One minor limitation is that wiki links do not parse in the callout's header section (works in body), although other markdown stuff does just as in Obsidian. For eg ..

> [!tip] # custom title // this works (parses the title as h1)

> [!tip] [[wiki-link]] // this doesn't -->  shows Tip instead

> [!tip]
> [[wiki-link]] // this works

I will update the tasks shortly.

rufuspollock commented 2 years ago

@khalilcodes amazing! πŸ‘ πŸ‘ let's integrate it and deploy it!