Linkify Words

By the first look on https://github.com/discourse/discourse-linkify-words/blob/master/common/head_tag.html It looks like you need to replace middle part of a script.

  1. Attach word-link script, so WordLink module is available in a scope.
  2. Get words to be replaced from settings.linked_words variable.
  3. Apply WordLink to the text like the following:
const linkify = function(element) {
  const newElement = element.cloneNode(true);

  newElement.innerHTML = WordLink.apply(element.innerHTML, word, url);
  
  return newElement;
};

api.decorateCooked(linkify);

I haven’t tested the code, it may require some corrections.

2 Likes