private string DewikifyLinkIn(string pageIn, string linkToDewikify, ParserUtils parser) { var links = ParserUtils.FindLinksTo(pageIn, linkToDewikify); var found = new List <WikiLink>(); var isDisambig = parser.FindTemplates(pageIn, DisambigTemplateName).Any() || parser.FindTemplates(pageIn, NamesakeListTemplateName).Any(); foreach (var link in links.ToArray()) { if (isDisambig || GetSectionName(links, link) == SeeAlsoSectionName) { found.Add(link); // whole line will be removed later (see below) } else { links.Update(link, link.Text ?? link.Link); } } var text = links.Text; // now removing whole lines return(text.Remove(found.Select(x => ParserUtils.GetWholeLineAt(links, x)).Distinct())); }