Skip to content

Commit

Permalink
there's no tail in the match anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
balpha committed Jan 28, 2013
1 parent 8349bfa commit 4c1e27f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions MarkdownSharp/Markdown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1458,11 +1458,11 @@ private static string handleTrailingParens(Match match)
// the google link to not be matched again.
if (match.Groups[1].Success)
return match.Value;

var protocol = match.Groups[2].Value;
var link = match.Groups[3].Value;
var tail = match.Groups[4].Value;
if (!link.EndsWith(")"))
return "<" + protocol + link + ">" + tail;
return "<" + protocol + link + ">";
var level = 0;
foreach (Match c in Regex.Matches(link, "[()]"))
{
Expand All @@ -1478,9 +1478,10 @@ private static string handleTrailingParens(Match match)
level--;
}
}
var tail = "";
if (level < 0)
{
link = Regex.Replace(link, @"\){1," + (-level) + "}$", m => { tail = m.Value + tail; return ""; });
link = Regex.Replace(link, @"\){1," + (-level) + "}$", m => { tail = m.Value; return ""; });
}
return "<" + protocol + link + ">" + tail;
}
Expand Down

0 comments on commit 4c1e27f

Please sign in to comment.