Help me debug plugin


(Tuan Anh Tran) #1

So i saw this post on how to write a plugin to manipulate text in the composer

I want a plugin to : whenever see a new line char, replace it with 2 new line chars. since markdown doesn’t create new paragraph on new line and a lots of users get confused with this.

so i forked it and replace the js file content with this.

function doubleNewline (text) {
  return text.trim().replace(/\r\n|\r|\n/gm, "\n\n");
}

Discourse.Dialect.postProcessText(function (text) {
  // markdown only add new paragraph on double new line
  text = [].concat(text);
  for (var i = 0; i < text.length; i++) {
    if (text[i].length > 0 && text[i][0] !== "<") {
      text[i] = doubleNewline(text[i]);
    }
  }
  return text;
});

i add my repo to app.yml and everything seems ok but the plugin is not working.

any idea?


(Kane York) #2

postProcessText sounds like it takes affect after everything is done… Try inserting that function earlier in the pipeline.


(Tuan Anh Tran) #3

Thank you. Could you be more specific?

According to the tutorial i mentioned above, it seems to work on preview panel as soon as user type.