User:Stepshep/tagging code

From Wikipedia, the free encyclopedia

public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
        {
            Skip = false;
            Summary = "";
            string Tag = "";
            string template = "WPOHIO";
 
            Match m = Regex.Match(ArticleText, @"\{\{" + template + "(.*?)\\|(.*?)class=", RegexOptions.Singleline | RegexOptions.IgnoreCase);
            Match c = Regex.Match(ArticleText, @"\|class=stub", RegexOptions.IgnoreCase);
            Match f = Regex.Match(ArticleText, @"\|class=fa", RegexOptions.IgnoreCase);
            Match l = Regex.Match(ArticleText, @"\|class=fl", RegexOptions.IgnoreCase);
            Match g = Regex.Match(ArticleText, @"\|class=ga", RegexOptions.IgnoreCase);
            Match s = Regex.Match(ArticleText, @"\|class=start", RegexOptions.IgnoreCase);
            Match b = Regex.Match(ArticleText, @"\|class=b", RegexOptions.IgnoreCase);
            Match r = Regex.Match(ArticleText, @"\|class=list", RegexOptions.IgnoreCase);
 
            string pageClass = "";
 
            if (c.Success) pageClass = "Stub";
 
            if (f.Success) pageClass = "FA";
 
            if (l.Success) pageClass = "FL";
 
            if (g.Success) pageClass = "GA";
 
            if (s.Success) pageClass = "Start";
 
            if (b.Success) pageClass = "B";            
 
            if (r.Success) pageClass = "List";
 
            Tag = "{{" + template + "|class=" + pageClass + "}}";
 
            if (m.Success) ArticleText = ArticleText.Insert(m.Index + m.Length, pageClass);
            else ArticleText = Tag + "\r\n" + ArticleText;
 
            return ArticleText;
        }

Stolen from Richard0612, which was tweaked by Reedy, which was slightly modified by me. The code is a custom module for AWB.