ux/Showdown.js
[roojs1] / ux / Showdown.js
index e519c19..8570de9 100644 (file)
@@ -878,13 +878,38 @@ Roo.ux.Showdown.converter = function() {
     
                             codeblock = "<pre><code>" + codeblock + "\n</code></pre>";
     
-                            return hashBlock(codeblock) + nextChar;
+                            return hashBlock(codeblock) ;
                     }
             );
     
             // 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) + nextChar;
+            });
+          
+            // attacklab: strip sentinel
+            text = text.replace(/~0/, '');
+
+        
+    
+    
+    
             return text;
     }
     
@@ -1237,7 +1262,7 @@ Roo.ux.Showdown.converter = function() {
             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;
     }