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

This commit is contained in:
Titus 2012-06-14 00:18:04 -06:00
parent f3f928084e
commit bcf2bafc44

View File

@ -131,6 +131,10 @@ this.makeHtml = function(text) {
// contorted like /[ \t]*\n+/ . // contorted like /[ \t]*\n+/ .
text = text.replace(/^[ \t]+$/mg,""); text = text.replace(/^[ \t]+$/mg,"");
// Handle github codeblocks prior to running HashHTML so that
// HTML contained within the codeblock gets escaped propertly
text = _DoGithubCodeBlocks(text);
// Turn block-level HTML blocks into hash entries // Turn block-level HTML blocks into hash entries
text = _HashHTMLBlocks(text); text = _HashHTMLBlocks(text);
@ -148,7 +152,7 @@ this.makeHtml = function(text) {
text = text.replace(/~T/g,"~"); text = text.replace(/~T/g,"~");
return text; return text;
} };
var _StripLinkDefinitions = function(text) { var _StripLinkDefinitions = function(text) {
@ -355,7 +359,6 @@ var _RunBlockGamut = function(text) {
text = text.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,key); text = text.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,key);
text = _DoLists(text); text = _DoLists(text);
text = _DoGithubCodeBlocks(text);
text = _DoCodeBlocks(text); text = _DoCodeBlocks(text);
text = _DoBlockQuotes(text); text = _DoBlockQuotes(text);
@ -367,7 +370,7 @@ var _RunBlockGamut = function(text) {
text = _FormParagraphs(text); text = _FormParagraphs(text);
return text; return text;
} };
var _RunSpanGamut = function(text) { var _RunSpanGamut = function(text) {
@ -910,7 +913,6 @@ var _DoGithubCodeBlocks = function(text) {
var language = m1; var language = m1;
var codeblock = m2; var codeblock = m2;
console.log('codeblock', '|' + codeblock + '|');
codeblock = _EncodeCode(codeblock); codeblock = _EncodeCode(codeblock);
codeblock = _Detab(codeblock); codeblock = _Detab(codeblock);
codeblock = codeblock.replace(/^\n+/g,""); // trim leading newlines codeblock = codeblock.replace(/^\n+/g,""); // trim leading newlines