WikiFunctions.Parse.MetaDataSorter.MoveExternalLinks C# (CSharp) Method

MoveExternalLinks() public static method

Ensures the external links section of an article is after the references section
public static MoveExternalLinks ( string articleText ) : string
articleText string The wiki text of the article.
return string
        public static string MoveExternalLinks(string articleText)
        {
            string articleTextAtStart = articleText;
            // is external links section above references?
            Match elm = ExternalLinksSection.Match(articleText);
            string externalLinks = elm.Groups[1].Value;

            // validate no <ref> in external links section
            if (!elm.Success || Regex.IsMatch(externalLinks, WikiRegexes.ReferenceEnd))
                return articleTextAtStart;

            string references = ReferencesSection.Match(articleText).Groups[1].Value;

            // references may be last section
            if (references.Length == 0)
                references = ReferencesToEnd.Match(articleText).Value;

            if (references.Length > 0 && elm.Index < articleText.IndexOf(references))
            {
                articleText = articleText.Replace(externalLinks, "");
                articleText = articleText.Replace(references, references + externalLinks);
            }

            return articleText;
        }