inlineRegexp with the new Markdown-it

Hello,
Had a few plugins that utilized inlineRegexp and worked great until the switch to Markdown-it.

I’m completely lost with the new markdown-it… Any suggestion or example plugins that I might be able to look at?

My regex matcher was something like:

matcher: /^\[custom-tag1:([a-z]{2}\d{10})(?:\:([a-z0-9_-]+))?\]/i,

Any help or suggestions would be greatly appreciated!

Have a look at https://github.com/discourse/discourse/blob/master/app/assets/javascripts/pretty-text/engines/discourse-markdown/mentions.js.es6 , the one issue though is that I do not yet support capture groups, I will see if I can add that.

4 Likes

Thanks, it really helps to see a working example!

OK, per:

https://github.com/discourse/discourse/commit/44fb2a2833d5ce644aeaaee32b20c034cf781915

We now support multiple capture groups each the rule, this should make it way easier to implement your plugin.

6 Likes