MarkdownIt inline renderer

I'm writing a plugin which will need the use of markdownIt. The demo plugin only shows the use of a fenced block, but I need to use an inline renderer.

I need to be able to write something on the editor and convert it to some value on the viewer, e.g.:

Editor Viewer
@myCoolVariable This is the text stored in my cool variable

I searched through the markdown-it API documentation for some insight but I could't get too much.

I just solved it using the powerful console.log(object_that_i_dont_know_how_its_made), but just with console.log(markdownIt.renderer.rules).
From that I assumed that the code from the demo plugin could be easily adapted to any of the renderer rules.
BTW the rule I used for the plugin I'm writing is text:

plugin: function (markdownIt, _options) {
			const defaultRender = markdownIt.renderer.rules.text || function (tokens, idx, options, env, self) {
				return self.renderToken(tokens, idx, options, env, self);

			markdownIt.renderer.rules.text = function (tokens, idx, options, env, self) {
				const token = tokens[idx];

and instead of the, I used token.content property.

1 Like