This might be a very noob question, but I am very new to coding so bear with me here;
Is there any way to make a plugin with custom markdown spec?
I use a website with some custom markdown. Basically, if you write imgXX(linkHere) you get an image of the XX width (in numbers). That and ~~~ doesn’t make a codeblock, but centers text. The latter isn’t all that important, but I find the imgXX command to be incredibly handy and easy to use.
So yeah, if anyone could point me in the right direction for how to do this, as maybe I’m just not searching the right keywords or something, but I can’t find any information on how to do this ...
Afaik yes. I think there might be an example plugin available. Check out the toc plugin.
~~~ shouldn't make a code block. I can't recall this being markdown specification. I think this is a bug.
Update: sorry, it is actually in the specs as a fenced code block. Well, adding features via a plugin certainly makes sense, but changing the behavior of markdown not so much IMO. But I guess you can also write a plugin for that.
I can see what you mean here. I don't really need this one specifically though as I can always just use HTML center command for that. But I would really like
Oh, for some reason I think I didn't quite understand the toc example last time. I'll try this using that as a guideline and in case I'm stuck, I'll ask again. Thanks for the help
A custom Markdown-it plugin could achieve that - you would parse the note and search for the
imgXX(link) pattern and replace this by the image at the right dimensions.
The plugin would be a "content script" as described here: https://joplinapp.org/api/references/plugin_api/classes/joplinplugins.html#registercontentscript
There's a demo link in that page, and check also the definition of ContentScriptType as it has more information: https://joplinapp.org/api/references/plugin_api/enums/contentscripttype.html
Thanks! I’ll look more into this tomorrow as it’s getting a bit late now.
I found a similar plugin for Markdown-It, so I’ll see if I may be able to customise that one to work with the formating I want to use. Or even get it to work in the first place as is.
I would just use something that is not already used by markdown. e.g.
The reason I’m doing this in the first place is because I want to use Joplin to backup my posts on a website I frequently use. Adding custom spec which doesn’t align with that site’s spec means I need to add some conversion layer between the two APIs.
But I did also realise I could probably just do a regex between the two APIs and replace the text like that. I tested this out (without using APIs, just copy-pasting) with this code already and that worked for images:
<img src="$3" width="$2"/>
Now to figure out if I can somehow do spoilers in Joplin using HTML or markdown, as I believe that’s the only extra thing that site has but Joplin seems not to.
Edit: fixed the expression as it only worked in some specific cases. Now it should be more general