Modifying the renderer in a plugin

I am familiar with GFM (github flavoured markdown). As amazing as Joplin is, I'm running into a few issues with it not following GFM and throwing off my expectations. When I reported an issue about this I was told to implement what I want as a plugin.

I've looked into it, however it's not entirely clear to me how I can modify the way the renderer does things. For example, if I wanted to unload some markdown-it plugin (because I want the tabs in my codeblocks to remain tabs), how would I accomplish that?

Take a look here:

Notice how this demo plugins redefines the renderer for fence but calls the default if the token is not justtesting. You can just not call the default and always use your renderer which can just do nothing.

Hope it makes sense.

Hmm. Well, that's a possibility, but honestly it doesn't quite do what I am looking for. There are some plugins that cannot be disabled through the settings, that I want to disable. Going this route would mean having to hardcode the original functionality of the renderer that they replaced... I can do that now, but it would mean having to keep my plugin in sync with upstream markdown-it and that doesn't scale.

One idea I had was to implement all the different markdown extensions that are currently in Joplin core as Joplin plugins, then opening a PR to remove them from core, but I don't know if the maintainers are open to that approach.

What exactly are you trying to do?

For now:

  1. Disable the checkbox rule (and replace it with the markdown-it-task-lists plugin).
  2. Disable the markdown-it-expand-tabs plugin.

In a plugin you have access to an instance of MarkdownIt, so I believe you can do that assuming its API allows it.

I'm not sure I understand what you mean.

Something like this should disable the checkbox rule (based on the plugin I linked above):

		plugin: function(markdownIt, _options) {
				markdownId.disable('checkbox');
		},
1 Like

That's helpful indeed. But what about the other one, where the original rule is overwritten?