Preserve whitespace in gollum code blocks.
This commit is contained in:
@@ -1025,14 +1025,14 @@ else
|
|||||||
//
|
//
|
||||||
// Gollum wraps code in one pre. Use ` to mark code pre.
|
// Gollum wraps code in one pre. Use ` to mark code pre.
|
||||||
// Gollum requires exactly three starting and ending `.
|
// Gollum requires exactly three starting and ending `.
|
||||||
// All regex set to use 'm' multiline option.
|
|
||||||
//
|
//
|
||||||
text = text.replace(/(^|[^\\])(`{3})([^\r]*?[^`])\2(?!`)/gm,
|
text = text.replace(/(^|[^\\])(`{3})([^\r]*?[^`])\2(?!`)/gm,
|
||||||
function (wholeMatch, m1, m2, m3, m4) {
|
function (wholeMatch, m1, m2, m3, m4) {
|
||||||
var c = m3;
|
var c = m3;
|
||||||
c = c.replace(/^([ \t]*)/gm, ""); // leading whitespace
|
c = c.replace(/^([ \t]*)/g, ""); // leading whitespace
|
||||||
c = c.replace(/[ \t]*$/gm, ""); // trailing whitespace
|
c = c.replace(/[ \t]*$/g, ""); // trailing whitespace
|
||||||
c = _EncodeCode(c);
|
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.
|
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>");
|
return m1 + hashBlock("<pre>`" + c + "</pre>");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user