From 6645ca173bab62a7ec530a5626522426a8f98935 Mon Sep 17 00:00:00 2001 From: Adam Backstrom Date: Fri, 19 Oct 2012 11:55:49 -0400 Subject: [PATCH] Apply sentinel fixes to _StripLinkDefinitions --- src/showdown.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/showdown.js b/src/showdown.js index 869d753..508d2c5 100644 --- a/src/showdown.js +++ b/src/showdown.js @@ -184,7 +184,11 @@ var _StripLinkDefinitions = function(text) { /gm, function(){...}); */ - var text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm, + + // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug + text += "~0"; + + var text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|(?=~0))/gm, function (wholeMatch,m1,m2,m3,m4) { m1 = m1.toLowerCase(); g_urls[m1] = _EncodeAmpsAndAngles(m2); // Link IDs are case-insensitive @@ -201,6 +205,9 @@ var _StripLinkDefinitions = function(text) { } ); + // attacklab: strip sentinel + text = text.replace(/~0/,""); + return text; }