osternaudClem
9/16/2016 - 7:32 PM

Match custom markdown tags

Match custom markdown tags

customMarkdown(content) {
  const regexCode = /\[[\s\S]*?\][\s\S]*?\[\/[\s\S]*?\]/g;
  let codeMarkup = content.match(regexCode);

  if (codeMarkup) {
    codeMarkup.forEach(code => {
      let button = code.replace(/\[/g, '<');
      button = button.replace(/\]/g, '>');
      content = content.replace(code, button);
    });
  }

  return content;
}