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

MoveSisterlinks() public static method

Moves sisterlinks such as {{wiktionary}} to the external links section
public static MoveSisterlinks ( string articleText ) : string
articleText string The article text
return string
        public static string MoveSisterlinks(string articleText)
        {
            string originalArticletext = articleText;
            foreach (Match m in WikiRegexes.SisterLinks.Matches(articleText))
            {
                string sisterlinkFound = m.Value;
                string ExternalLinksSectionString = ExternalLinksSection.Match(articleText).Value;

                // if ExteralLinksSection didn't match then 'external links' must be last section
                if (ExternalLinksSectionString.Length == 0)
                    ExternalLinksSectionString = ExternalLinksToEnd.Match(articleText).Value;

                // need to have an 'external links' section to move the sisterlinks to
                // check sisterlink NOT currently in 'external links'
                if (ExternalLinksSectionString.Length > 0 && !ExternalLinksSectionString.Contains(sisterlinkFound.Trim()))
                {
                    articleText = Regex.Replace(articleText, Regex.Escape(sisterlinkFound) + @"\s*(?:\r\n)?", "");
                    articleText = WikiRegexes.ExternalLinksHeader.Replace(articleText, "$0" + "\r\n" + sisterlinkFound);
                }
            }

            if (Tools.UnformattedTextNotChanged(originalArticletext, articleText))
                return articleText;

            return originalArticletext;
        }