HasRefAfterReflist() public static method

Check if the article contains a <ref>...</ref> reference after the {{reflist}} to show them
public static HasRefAfterReflist ( string articleText ) : bool
articleText string
return bool
Example #1
0
        // http://en.wikipedia.org/wiki/Wikipedia_talk:AutoWikiBrowser/Feature_requests#Place_.22External_links.22_section_after_.22References.22
        // TODO: only works when there is another section following the references section
        /// <summary>
        /// Ensures the external links section of an article is after the references section
        /// </summary>
        /// <param name="articleText">The wiki text of the article.</param>
        /// <returns>Article text with external links section below the references section</returns>
        public static string MoveExternalLinks(string articleText)
        {
            string articleTextAtStart = articleText;
            // is external links section above references?
            string externalLinks = ExternalLinksSection.Match(articleText).Groups[1].Value;
            string references    = ReferencesSection.Match(articleText).Groups[1].Value;

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

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

            // newlines are fixed by later logic; validate no <ref> in external links section
            if (!Parsers.HasRefAfterReflist(articleText))
            {
                return(articleText);
            }
            else
            {
                return(articleTextAtStart);
            }
        }