REFACTOR: Move the `discourse-markdown` engine out of the addon repo

REFACTOR: Move the discourse-markdown engine out of the addon repo

The reasoning here is that we want to make a unique bundle for this folder and the default approach is to include everything in addon.

diff --git a/app/assets/javascripts/markdown-it-bundle.js b/app/assets/javascripts/markdown-it-bundle.js
index 2299af2..052891a 100644
--- a/app/assets/javascripts/markdown-it-bundle.js
+++ b/app/assets/javascripts/markdown-it-bundle.js
@@ -1,20 +1,20 @@
 //= require markdown-it.js
-//= require ./pretty-text/addon/engines/discourse-markdown/helpers
-//= require ./pretty-text/addon/engines/discourse-markdown/mentions
-//= require ./pretty-text/addon/engines/discourse-markdown/quotes
-//= require ./pretty-text/addon/engines/discourse-markdown/emoji
-//= require ./pretty-text/addon/engines/discourse-markdown/onebox
-//= require ./pretty-text/addon/engines/discourse-markdown/bbcode-block
-//= require ./pretty-text/addon/engines/discourse-markdown/bbcode-inline
-//= require ./pretty-text/addon/engines/discourse-markdown/code
-//= require ./pretty-text/addon/engines/discourse-markdown/category-hashtag
-//= require ./pretty-text/addon/engines/discourse-markdown/censored
-//= require ./pretty-text/addon/engines/discourse-markdown/table
-//= require ./pretty-text/addon/engines/discourse-markdown/paragraph
-//= require ./pretty-text/addon/engines/discourse-markdown/newline
-//= require ./pretty-text/addon/engines/discourse-markdown/html-img
-//= require ./pretty-text/addon/engines/discourse-markdown/text-post-process
-//= require ./pretty-text/addon/engines/discourse-markdown/upload-protocol
-//= require ./pretty-text/addon/engines/discourse-markdown/inject-line-number
-//= require ./pretty-text/addon/engines/discourse-markdown/resize-controls
-//= require ./pretty-text/addon/engines/discourse-markdown/d-wrap
+//= require ./pretty-text/engines/discourse-markdown/helpers
+//= require ./pretty-text/engines/discourse-markdown/mentions
+//= require ./pretty-text/engines/discourse-markdown/quotes
+//= require ./pretty-text/engines/discourse-markdown/emoji
+//= require ./pretty-text/engines/discourse-markdown/onebox
+//= require ./pretty-text/engines/discourse-markdown/bbcode-block
+//= require ./pretty-text/engines/discourse-markdown/bbcode-inline
+//= require ./pretty-text/engines/discourse-markdown/code
+//= require ./pretty-text/engines/discourse-markdown/category-hashtag
+//= require ./pretty-text/engines/discourse-markdown/censored
+//= require ./pretty-text/engines/discourse-markdown/table
+//= require ./pretty-text/engines/discourse-markdown/paragraph
+//= require ./pretty-text/engines/discourse-markdown/newline
+//= require ./pretty-text/engines/discourse-markdown/html-img
+//= require ./pretty-text/engines/discourse-markdown/text-post-process
+//= require ./pretty-text/engines/discourse-markdown/upload-protocol
+//= require ./pretty-text/engines/discourse-markdown/inject-line-number
+//= require ./pretty-text/engines/discourse-markdown/resize-controls
+//= require ./pretty-text/engines/discourse-markdown/d-wrap
diff --git a/app/assets/javascripts/pretty-text/addon/engines/discourse-markdown/bbcode-block.js b/app/assets/javascripts/pretty-text/addon/engines/discourse-markdown/bbcode-block.js
deleted file mode 100644
index 95eb279..0000000
--- a/app/assets/javascripts/pretty-text/addon/engines/discourse-markdown/bbcode-block.js
+++ /dev/null
@@ -1,372 +0,0 @@
-let isWhiteSpace;
-
-function trailingSpaceOnly(src, start, max) {
-  let i;
-  for (i = start; i < max; i++) {
-    let code = src.charCodeAt(i);
-    if (code === 0x0a) {
-      return true;
-    }
-    if (!isWhiteSpace(code)) {
-      return false;
-    }
-  }
-
-  return true;
-}
-
-const ATTR_REGEX = /^\s*=(.+)$|((([a-z0-9]*)\s*)=)(["“”'].*?["“”']|\S+)/gi;
-
-// parse a tag [test a=1 b=2] to a data structure
-// {tag: "test", attrs={a: "1", b: "2"}
-export function parseBBCodeTag(src, start, max, multiline) {
-  let i;
-  let tag;
-  let attrs = {};
-  let closed = false;
-  let length = 0;
-  let closingTag = false;
-
-  // closing tag
-  if (src.charCodeAt(start + 1) === 47) {
-    closingTag = true;
-    start += 1;
-  }
-
-  for (i = start + 1; i < max; i++) {
-    let letter = src[i];
-    if (
-      !((letter >= "a" && letter <= "z") || (letter >= "A" && letter <= "Z"))
-    ) {
-      break;
-    }
-  }
-
-  tag = src.slice(start + 1, i);
-
-  if (!tag) {
-    return;
-  }
-
-  if (closingTag) {
-    if (src[i] === "]") {
-      if (multiline && !trailingSpaceOnly(src, i + 1, max)) {
-        return;
-      }
-
-      tag = tag.toLowerCase();
-
-      return { tag, length: tag.length + 3, closing: true };
-    }
-    return;
-  }
-
-  for (; i < max; i++) {
-    let letter = src[i];
-
-    if (letter === "]") {
-      closed = true;
-      break;
-    }
-  }
-
-  if (closed) {
-    length = i - start + 1;
-
-    let raw = src.slice(start + tag.length + 1, i);
-
-    // trivial parser that is going to have to be rewritten at some point
-    if (raw) {
-      let match, key, val;
-
-      while ((match = ATTR_REGEX.exec(raw))) {
-        if (match[1]) {
-          key = "_default";
-        } else {
-          key = match[4];
-        }
-
-        val = match[1] || match[5];
-
-        if (val) {
-          val = val.trim();
-          val = val.replace(/^["'“”](.*)["'“”]$/, "$1");
-          attrs[key] = val;
-        }
-      }
-    }
-
-    if (multiline && !trailingSpaceOnly(src, start + length, max)) {
-      return;
-    }
-
-    tag = tag.toLowerCase();
-
-    return { tag, attrs, length };
-  }
-}
-
-function findBlockCloseTag(state, openTag, startLine, endLine) {
-  let nesting = 0,
-    line = startLine - 1,
-    start,
-    closeTag,
-    max;
-
-  for (;;) {
-    line++;
-    if (line >= endLine) {
-      // unclosed bbcode block should not be autoclosed by end of document.
-      return;
-    }
-
-    start = state.bMarks[line] + state.tShift[line];
-    max = state.eMarks[line];
-
-    if (start < max && state.sCount[line] < state.blkIndent) {
-      // non-empty line with negative indent should stop the list:
-      // - `‍``
-      //  test
-      break;
-    }
-
-    // bbcode close [ === 91
-    if (91 !== state.src.charCodeAt(start)) {
-      continue;
-    }
-
-    if (state.sCount[line] - state.blkIndent >= 4) {
-      // closing bbcode less than 4 spaces
-      continue;
-    }
-
-    closeTag = parseBBCodeTag(state.src, start, max, true);
-
-    if (closeTag && closeTag.closing && closeTag.tag === openTag.tag) {
-      if (nesting === 0) {
-        closeTag.line = line;
-        closeTag.block = true;
-        break;
-      }
-      nesting--;
-    }
-
-    if (closeTag && !closeTag.closing && closeTag.tag === openTag.tag) {
-      nesting++;
-    }
-
-    closeTag = null;
-  }
-
-  return closeTag;
-}
-
-function findInlineCloseTag(state, openTag, start, max) {
-  let closeTag;
-  let possibleTag = false;
-
-  for (let j = max - 1; j > start; j--) {
-    if (!possibleTag) {
-      if (state.src.charCodeAt(j) === 93 /* ] */) {
-        possibleTag = true;
-        continue;
-      }
-      if (!isWhiteSpace(state.src.charCodeAt(j))) {
-        break;
-      }
-    } else {
-      if (state.src.charCodeAt(j) === 91 /* [ */) {
-        closeTag = parseBBCodeTag(state.src, j, max);
-        if (!closeTag || closeTag.tag !== openTag.tag || !closeTag.closing) {
-          closeTag = null;
-        } else {
-          closeTag.start = j;
-          break;
-        }
-      }
-    }
-  }
-
-  return closeTag;
-}
-
-function applyBBCode(state, startLine, endLine, silent, md) {
-  var nextLine,
-    oldParent,
-    oldLineMax,
-    rule,
-    start = state.bMarks[startLine] + state.tShift[startLine],
-    initial = start,
-    max = state.eMarks[startLine];
-
-  // [ === 91
-  if (91 !== state.src.charCodeAt(start)) {
-    return false;
-  }
-
-  let info = parseBBCodeTag(state.src, start, max);
-
-  if (!info || info.closing) {
-    return false;
-  }
-
-  let ruleInfo = md.block.bbcode.ruler.getRuleForTag(info.tag);
-  if (!ruleInfo) {
-    return false;
-  }
-
-  rule = ruleInfo.rule;
-
-  // Since start is found, we can report success here in validation mode

[... diff too long, it was truncated ...]

GitHub sha: f3156a64