Footnotes support

Hey everyone,

I’d like to take a stab at adding footnotes support in silverbullet. Perusing over the code yesterday, it seems that I’d have to start from Codemirror as support is seemingly lacking there. And thus add it to lezer-markdown which is the underlying library used for parsing.

Does that sound about right?

I’d also be interested in tweaking the link rendering a bit. I’ve gotten into the habit of opening pages in incognito mode, but use silverbullet as a PWA so I need to somehow find a way to copy the url. Right now it seems there’ s a mouseup event that fires on right clicks too which makes things more cumbersome for me, so I was thinking to write a space-script to add some button next to external links somehow; it seems though that I can’t do that within the editor.

Any tricks I’m missing on this one?

Many thanks!

Yes, you need to expand the markdown parser to do this. SilverBullet already contains a few markdown extensions that you can add to. This would be your starting point: silverbullet/common/markdown_parser/parser.ts at main · silverbulletmd/silverbullet · GitHub

Checking if there’s no footnote support in Lezer’s markdown parser already, I came across this repo: GitHub - erykwalder/lezer-markdown-obsidian: Obsidian Markdown extensions for @lezer/markdown which among other things seems to include a footnote parser. So this is perhaps something you can be “inspired by” :slight_smile:

Ah neat, thanks for the pointer! This would be for the markdown preview though right? I don’t use this as much, I mostly rely on the editor view which is good enough for me tbh. That would require Codemirror changes to support footnotes (it seems Codemirror uses the same library anyway so it’s not lost on me).

On the other point, is there a way to customize the editor directly too (say adding a short icon/button next to links which is what I’d like to do (or change the behaviour of links altogether)?