From: Alan Knowles Date: Tue, 18 Oct 2016 08:11:34 +0000 (+0800) Subject: ux/Showdown.js X-Git-Url: http://git.roojs.org/?p=roojs1;a=commitdiff_plain;h=7c0bd531236c7cc036b5f3368556159c03ba11a0 ux/Showdown.js --- diff --git a/ux/Showdown.js b/ux/Showdown.js index 18eee4f213..af8927d06d 100644 --- a/ux/Showdown.js +++ b/ux/Showdown.js @@ -885,6 +885,31 @@ Roo.ux.Showdown.converter = function() { // 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 = '
' + codeblock + end + '
'; + + return hashBlock(codeblock) + nextChar; + }); + + // attacklab: strip sentinel + text = text.replace(/~0/, ''); + + + + + return text; }