private static string SelfLinks(string zerothSection, string articleTitle)
{
string zerothSectionOriginal = zerothSection, escTitle = Regex.Escape(articleTitle);
if (!zerothSection.Contains("'''" + articleTitle + "'''"))
{
Regex r1 = new Regex(@"\[\[\s*" + escTitle + @"\s*\]\]");
Regex r3 = new Regex(@"\[\[\s*" + escTitle + @"\s*\|\s*([^\[\]]+?)\s*\]\]");
zerothSection = r1.Replace(zerothSection, "'''" + articleTitle + @"'''");
zerothSection = r3.Replace(zerothSection, "'''$1'''");
}
if (zerothSectionOriginal.Equals(zerothSection) && !zerothSection.Contains("'''" + Tools.TurnFirstToLower(articleTitle) + "'''"))
{
Regex r2 = new Regex(@"\[\[\s*" + Tools.TurnFirstToLower(escTitle) + @"\s*\]\]");
Regex r4 = new Regex(@"\[\[\s*" + Tools.TurnFirstToLower(escTitle) + @"\s*\|\s*([^\[\]]+?)\s*\]\]");
zerothSection = r2.Replace(zerothSection, "'''" + Tools.TurnFirstToLower(articleTitle) + @"'''");
zerothSection = r4.Replace(zerothSection, "'''$1'''");
}
return zerothSection;
}