In my Plugin, the user is able to insert research references into the note body in the current cursor position. However, the inserted text is a short form of the complete reference, like (Smith 2015). So, I want to do one extra thing: render a full list of references at the bottom of the note viewer like this:
- Statistical mechanics describes how macroscopic observations are related to microscopic parameters that fluctuate around an average (Smith 2015)
I was planning to use a markdown-it plugin to do that, but all the resources I found were about rendering a single token in the same place where it was inserted. So, can anyone guide me on how to accomplish such a thing? Or maybe there is a better approach without the need for a markdown-it plugin?
Thanks in advance
But why not just have it render in the same place it was inserted ? It's easier that way and in fact, you can just use the table-of-contents plugin as reference.
People would have the freedom to enable it or not instead of forcing it on the user. Maybe they don't want it at the very end ? (I'm not sure where else would you put it.. But still lol)
I just prefer having it as a token
[[references]]. It is more flexible.
To render some arbitrary content, you could add a core rule, as is done for the checkboxes: joplin/checkbox.ts at a8bc9d2a63f3ed75e93910c72bbc3dff0a5df956 · laurent22/joplin · GitHub
Markdown-it calls this only once and you get the complete list of tokens. Then you have two options I think:
Append a custom token for example called "reference_list", then you create a new renderer rule that convert this token into HTML.
Or you could directly add the HTML tokens to the token list, as is done in checkbox.ts
The references will be rendered at the bottom of the note viewer in addition to being rendered in the same place they were written in. With that said, I actually liked the idea of making it optional for users. I can, for example, register a checkbox in the config screen for that.
I think there was one plugin that did something similar to what you're looking for.
The idea is to add a custom token to the end of the list of all tokes and have a rule that handles this token to output whatever you want.