Thanks for your reply!
I stumbled upon your first link this afternoon.
The github link files are 7 years old so I suppose the code might be outdated?
Anyway, I used this:
export function setup(helper) {
if (!helper.markdownIt) { return; }
helper.registerOptions((opts, siteSettings) => {
opts.features.nolinkify = siteSettings.no_linkify_enabled;
});
helper.allowList(["span.nolinkify"]);
}
Which I borrowed from GitHub - unfoldingWord/discourse-mermaid: Adds the Mermaid JS library to discourse
There are only a few lines of code in my plugin and I don’t really know what it’s doing and if all is needed, but at least I can add spans with a nolinkify
class.
In my case, the purpose was to easily “unlinkify” words in posts with Linkify Words (it only accepts tags and classes to prevent linkification), and especially words in titles HTML tags while using DiscoTOC - automatic table of contents
I also tried a bbcode syntax based solution like this:
helper.registerPlugin(md => {
md.inline.bbcode.ruler.push("nolinkify",{
tag: "nolinkify",
replace: function(state, tagInfo, content) {
const token = state.push("html_raw", '', 0);
const escaped = state.md.utils.escapeHtml(content);
token.content = `<span="nolinkify ">${escaped}</span>`;
return true;
}
});
});
So, I tried both solutions for my title tags problem with the table of content.
This doesn’t work:
## [nolinkify]test[/nolinkify]
But this works:
## <span class="nolinkify">test</span>
I’d have preferred the first syntax, but I guess it’s incompatible with the table of content because of the scripts’ order of executions…