From 7c0bd531236c7cc036b5f3368556159c03ba11a0 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Tue, 18 Oct 2016 16:11:34 +0800 Subject: [PATCH] ux/Showdown.js --- ux/Showdown.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) 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; } -- 2.39.2