User:Reedy/AWB/LinkFixr

From Wikipedia, the free encyclopedia

User:Magnus Manske/LinkFixr.js

       public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
        {
            Skip = false;

            string s = get_linkfixr_text(ArticleText);

            if (s != ArticleText)
                Summary = "fixed link(s)";
            else
                Summary = "";

            return s;
        }

        private static string get_linkfixr_text(string ot)
        {
            string t = ot;

            string ct;
            do
            {
                ct = t;
                t = t.Replace(@"[[""", @"""[[");
                t = t.Replace(@"""]]", @"]]""");

                t = t.Replace("[['", "'[[");
                t = t.Replace("']]", "]]'");

                t = t.Replace(",]]", "]],");
                t = t.Replace(":]]", "]]:");
                t = t.Replace(";]]", "]];");

            } while (ct != t);

            return t;
        }