public string Parse(string input,
Func<HiveId, string> linkFoundCallback)
{
var s = TagMatch.Replace(input, x =>
{
var strLink = x.ToString();
// Links
if(HrefMatch.IsMatch(strLink))
{
var hiveId = new HiveId(HrefMatch.Match(strLink).Groups["Href"].Value);
var url = linkFoundCallback(hiveId);
strLink = HrefMatch.Replace(strLink, "href=\"" + url + "\"");
strLink = strLink.Replace(@"data-rebel-link=""internal""", "");
}
// Media
else if (SrcMatch.IsMatch(strLink) && RebelSrcMatch.IsMatch(strLink))
{
var hiveId = new HiveId(RebelSrcMatch.Match(strLink).Groups["Src"].Value);
var url = linkFoundCallback(hiveId);
if(!url.IsNullOrWhiteSpace())
{
strLink = SrcMatch.Replace(strLink, "src=\"" + url + "\"");
strLink = RebelSrcMatch.Replace(strLink, "");
strLink = strLink.Replace(@"data-rebel-link=""internal""", "");
}
else
{
strLink = "";
}
}
return strLink;
});
return s;
}
}