Preserve whitespace in gollum code blocks.

This commit is contained in:
bootstraponline
2012-05-15 11:20:01 -06:00
parent 3a91b076e1
commit f2a2d85008
@@ -1025,14 +1025,14 @@ else
//
// Gollum wraps code in one pre. Use ` to mark code pre.
// Gollum requires exactly three starting and ending `.
// All regex set to use 'm' multiline option.
//
text = text.replace(/(^|[^\\])(`{3})([^\r]*?[^`])\2(?!`)/gm,
function (wholeMatch, m1, m2, m3, m4) {
var c = m3;
c = c.replace(/^([ \t]*)/gm, ""); // leading whitespace
c = c.replace(/[ \t]*$/gm, ""); // trailing whitespace
c = c.replace(/^([ \t]*)/g, ""); // leading whitespace
c = c.replace(/[ \t]*$/g, ""); // trailing whitespace
c = _EncodeCode(c);
// Set to use 'm' multiline option.
c = c.replace(/:\/\//gm, "~P"); // to prevent auto-linking. Not necessary in code *blocks*, but in code spans. Will be converted back after the auto-linker runs.
return m1 + hashBlock("<pre>`" + c + "</pre>");
}