/*! codeFormatter v4.0.0 by ryanpcmcquen */
//
// Ryan McQuen

/*jslint browser*/

(function () {
    "use strict";

    var replacement = function (matchedText, language) {
        var codeBlock = document.createElement("code");
        var textNode = document.createTextNode(String(matchedText));
        if (language) {
            codeBlock.classList.add("prettyprint", "lang-" + language);
        }
        codeBlock.appendChild(textNode);

        return codeBlock;
    };

    var cleanReplace = function (i, regex, language) {
        return i.parentNode.replaceChild(
            replacement(i.textContent.match(regex), language),
            i
        );
    };

    var codeFormatter = function (selector) {
        var contentArray = Array.prototype.slice.call(
            document.querySelectorAll(selector)
        );

        // Multi-line code:
        var tripleTickRegex = new RegExp(/```{1}[\w\W]*?```$/gim);
        // Inline code:
        var singleTickRegex = new RegExp(/`[^`]+`/g);
        var codeLanguageRegex = new RegExp(/```{1}.*/);
        contentArray.map(function (i) {
            if (!(/<code/gi).test(i.innerHTML)) {
                // Match the code language, so we can support
                // a lot of awesome syntax highlighting.
                if (i.textContent && codeLanguageRegex.test(i.textContent)) {
                    // This needs a little extra filtering,
                    // but cascading is cool.
                    var codeLanguage = String(
                        i.textContent.match(codeLanguageRegex)
                    ).slice(3).split(/(\s+)/)[0].trim();

                    if (tripleTickRegex.test(i.textContent)) {
                        i.innerHTML = cleanReplace(
                            i,
                            tripleTickRegex,
                            codeLanguage
                        );
                    }
                }
                // Single tick regex only works if it is
                // outside the triple tick match:
                if (singleTickRegex.test(i.textContent)) {
                    i.innerHTML = cleanReplace(i, singleTickRegex);
                }
            }
        });
    };

    // Attach globally:
    window.codeFormatter = codeFormatter;
}());

@@ -215,19 +215,18 @@
 lement(%22
-cod
+pr
 e%22);%0A   
@@ -540,118 +540,208 @@
     
-return i.parentNode.replaceChild(%0A            replacement(i.textContent.match(regex), language),%0A            i
+var codeMatch = i.textContent.match(regex);%0A        while (i.firstChild) %7B%0A            i.removeChild(i.firstChild);%0A        %7D%0A        return i.appendChild(%0A            replacement(codeMatch, language)
 %0A   
@@ -1789,38 +1789,24 @@
             
- i.innerHTML =
  cleanReplac
@@ -1808,16 +1808,16 @@
 eplace(%0A
+
         
@@ -1983,33 +1983,82 @@
                %7D
-%0A
+ else if (singleTickRegex.test(i.textContent)) %7B%0A 
                 
@@ -2057,16 +2057,19 @@
         
+   
 // Singl
@@ -2101,16 +2101,20 @@
 f it is%0A
+    
         
@@ -2175,84 +2175,11 @@
     
-if (singleTickRegex.test(i.textContent)) %7B%0A                    i.innerHTML =
+   
  cle

Replace the child only, so that special attributes of the parent are preserved.