TypeError: Discourse.Dialect.postProcessText is not a function

You should see a console message saying it is deprecated.

I haven’t tested this, but I think this is close to what you’d want.

Create a file at /assets/javascripts/lib/discourse-markdown/pirate-speak.js.es6

import { registerOption } from 'pretty-text/pretty-text';

registerOption((siteSettings, opts) => {
  opts.features['pirate-speak'] = true;
});

function piratize (text) {
  return text.replace(/\b(am|are|is)\b/ig, "be")
             .replace(/ing\b/ig, "in'")
             .replace(/v/ig, "'");
}

export function setup(helper) {
  helper.postProcessText(function (text) {
    text = [].concat(text);
    for (var i = 0; i < text.length; i++) {
      if (text[i].length > 0 && text[i][0] !== "<") {
        text[i] = piratize(text[i]);
      }
    }
    return text;
  });
}

I haven’t actually tested this, but it should at least put you on the right track.

You can find more about the dialect helper at
https://github.com/discourse/discourse/blob/master/app/assets/javascripts/pretty-text/engines/discourse-markdown.js.es6

3 Likes