diff --git a/src/showdown.js b/src/showdown.js index f079f7f..de07e38 100644 --- a/src/showdown.js +++ b/src/showdown.js @@ -191,7 +191,7 @@ var _StripLinkDefinitions = function(text) { } else if (m4) { g_titles[m1] = m4.replace(/"/g,"""); } - + // Completely remove the definition from the text return ""; } @@ -264,7 +264,7 @@ var _HashHTMLBlocks = function(text) { text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,hashElement); // Special case just for
` blocks.
-//
+//
/*
text = text.replace(text,
@@ -867,12 +867,12 @@ var _DoCodeBlocks = function(text) {
// attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
text += "~0";
-
+
text = text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
function(wholeMatch,m1,m2) {
var codeblock = m1;
var nextChar = m2;
-
+
codeblock = _EncodeCode( _Outdent(codeblock));
codeblock = _Detab(codeblock);
codeblock = codeblock.replace(/^\n+/g,""); // trim leading newlines
@@ -899,23 +899,23 @@ var _DoGithubCodeBlocks = function(text) {
// puts "Hello, #{x}"
// end
// ```
-//
+//
// attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
text += "~0";
-
+
text = text.replace(/\n```(.*)\n([^`]+)\n```/g,
function(wholeMatch,m1,m2) {
var language = m1;
var codeblock = m2;
-
+
codeblock = _EncodeCode(codeblock);
codeblock = _Detab(codeblock);
codeblock = codeblock.replace(/^\n+/g,""); // trim leading newlines
codeblock = codeblock.replace(/\n+$/g,""); // trim trailing whitespace
- codeblock = "" + codeblock + "\n
";
+ codeblock = "" + codeblock + "\n
";
return hashBlock(codeblock);
}
@@ -935,26 +935,26 @@ var hashBlock = function(text) {
var _DoCodeSpans = function(text) {
//
// * Backtick quotes are used for
spans.
-//
+//
// * You can use multiple backticks as the delimiters if you want to
// include literal backticks in the code span. So, this input:
-//
+//
// Just type ``foo `bar` baz`` at the prompt.
-//
+//
// Will translate to:
-//
+//
// Just type foo `bar` baz
at the prompt.
-//
+//
// There's no arbitrary limit to the number of backticks you
// can use as delimters. If you need three consecutive backticks
// in your code, use four for delimiters, etc.
//
// * You can use spaces to get literal backticks at the edges:
-//
+//
// ... type `` `bar` `` ...
-//
+//
// Turns to:
-//
+//
// ... type `bar`
...
//
@@ -1056,7 +1056,7 @@ var _DoBlockQuotes = function(text) {
bq = bq.replace(/^[ \t]+$/gm,""); // trim whitespace-only lines
bq = _RunBlockGamut(bq); // recurse
-
+
bq = bq.replace(/(^|\n)/g,"$1 ");
// These leading spaces screw with content, so we need to fix that:
bq = bq.replace(
@@ -1068,7 +1068,7 @@ var _DoBlockQuotes = function(text) {
pre = pre.replace(/~0/g,"");
return pre;
});
-
+
return hashBlock("\n" + bq + "\n
");
});
return text;
@@ -1127,14 +1127,14 @@ var _FormParagraphs = function(text) {
var _EncodeAmpsAndAngles = function(text) {
// Smart processing for ampersands and angle brackets that need to be encoded.
-
+
// Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
// http://bumppo.net/projects/amputator/
text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&");
-
+
// Encode naked <'s
text = text.replace(/<(?![a-z\/?\$!])/gi,"<");
-
+
return text;
}