Skip to content
This repository
Browse code

Fixed #17 -- Github style codeblocks now escape HTML properly

  • Loading branch information...
commit bcf2bafc444a03a6500b5778a798bcf830255b2c 1 parent f3f9280
Titus authored June 14, 2012

Showing 1 changed file with 6 additions and 4 deletions. Show diff stats Hide diff stats

  1. 10  src/showdown.js
10  src/showdown.js
@@ -131,6 +131,10 @@ this.makeHtml = function(text) {
131 131
 	// contorted like /[ \t]*\n+/ .
132 132
 	text = text.replace(/^[ \t]+$/mg,"");
133 133
 
  134
+	// Handle github codeblocks prior to running HashHTML so that
  135
+	// HTML contained within the codeblock gets escaped propertly
  136
+	text = _DoGithubCodeBlocks(text);
  137
+
134 138
 	// Turn block-level HTML blocks into hash entries
135 139
 	text = _HashHTMLBlocks(text);
136 140
 
@@ -148,7 +152,7 @@ this.makeHtml = function(text) {
148 152
 	text = text.replace(/~T/g,"~");
149 153
 
150 154
 	return text;
151  
-}
  155
+};
152 156
 
153 157
 
154 158
 var _StripLinkDefinitions = function(text) {
@@ -355,7 +359,6 @@ var _RunBlockGamut = function(text) {
355 359
 	text = text.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,key);
356 360
 
357 361
 	text = _DoLists(text);
358  
-  text = _DoGithubCodeBlocks(text);
359 362
 	text = _DoCodeBlocks(text);
360 363
 	text = _DoBlockQuotes(text);
361 364
 
@@ -367,7 +370,7 @@ var _RunBlockGamut = function(text) {
367 370
 	text = _FormParagraphs(text);
368 371
 
369 372
 	return text;
370  
-}
  373
+};
371 374
 
372 375
 
373 376
 var _RunSpanGamut = function(text) {
@@ -910,7 +913,6 @@ var _DoGithubCodeBlocks = function(text) {
910 913
 			var language = m1;
911 914
 			var codeblock = m2;
912 915
 
913  
-			console.log('codeblock', '|' + codeblock + '|');
914 916
 			codeblock = _EncodeCode(codeblock);
915 917
 			codeblock = _Detab(codeblock);
916 918
 			codeblock = codeblock.replace(/^\n+/g,""); // trim leading newlines

0 notes on commit bcf2baf

Please sign in to comment.
Something went wrong with that request. Please try again.