// These are all the transformations that form block-level
// tags like paragraphs, headers, and list items.
//
+ // code blocks first... so content does not get translated..
+ text = _DoCodeBlocks(text);
+
text = _DoHeaders(text);
// Do Horizontal Rules:
text = text.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,key);
text = _DoLists(text);
- text = _DoCodeBlocks(text);
+
text = _DoBlockQuotes(text);
// We already ran _HashHTMLBlocks() before, in Markdown(), but that
// attacklab: strip sentinel
text = text.replace(/~0/,"");
+
+
+ text += '~0';
+
+ text = text.replace(/(?:^|\n)```(.*)\n([\s\S]*?)\n```/g, function (wholeMatch, language, codeblock) {
+ var end = '\n';
+
+ // First parse the github code block
+ codeblock = _EncodeCode( codeblock);
+ codeblock = _Detab(codeblock);
+ codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
+ codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing whitespace
+
+ codeblock = '<pre><code' + (language ? ' class="' + language + ' language-' + language + '"' : '') + '>' + codeblock + end + '</code></pre>';
+
+ return hashBlock(codeblock) ;
+ });
+
+ // attacklab: strip sentinel
+ text = text.replace(/~0/, '');
+
+
return text;
}
text = text.replace(/^(\t|[ ]{1,4})/gm,"~0"); // attacklab: g_tab_width
// attacklab: clean up hack
- text = text.replace(/~0/g,"")
+ text = text.replace(/~0/g,"");
return text;
}