public static string ModifiedSection(string originalText, string articleText)
{
string[] sectionsBefore = Tools.SplitToSections(originalText),
sectionsAfter = Tools.SplitToSections(articleText);
// if number of sections has changed, can't provide section edit summary
if (sectionsAfter.Length != sectionsBefore.Length)
return "";
int sectionsChanged = 0, sectionChangeNumber = 0;
for (int i = 0; i < sectionsAfter.Length; i++)
{
if (!sectionsBefore[i].Equals(sectionsAfter[i]))
{
sectionsChanged++;
sectionChangeNumber = i;
}
// if multiple sections changed, can't provide section edit summary
if (sectionsChanged > 1)
return "";
}
if(sectionsChanged == 0)
return "";
// so SectionsChanged == 1, get heading name from regex, or return "top" if zeroth section
string heading = WikiRegexes.Headings.Match(sectionsAfter[sectionChangeNumber]).Groups[1].Value.Trim();
return (heading.Length == 0 ? "top" : heading);
}