This is the AWB module used as the final step in the list-making for this nomination.
I have not prettified the code. This is how it was when I ran it as part of the list-making described in selection process.
I am an occasional hacker (of 40 years intermittent experience) and not a professional programmer, so the code is crude as hell and as ugly as a very ugly thing. But since it relies on a positive identification, I am confident that any flaws will lead to false negatives, rather than false positives.
It take a portal page, and then:
- tries to match a call to {{Transclude list item excerpts as random slideshow}}
- If not found, skip the page
- Convert each run of whitespace characters to a single space
- Strips everything except the parameters
- Strips up to 7 named parameters
- Strips up to 3 empty parameters from the end of the string. (I should have stripped any from the beginning too, but forgot. In the samples i viewed, that made no difference, but it may have led to some false negatives)
- Checks whether the remaining text is a single parameter beginning
Template:
- If it is NOT a
Template:
, skip the page
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip) { Skip = false; Summary = "test"; Match tsramatch = Regex.Match(ArticleText, @"\{\{Transclude +list +item +excerpts +as +random +slideshow[^\}]*\}\}", RegexOptions.Singleline); if (!tsramatch.Success) { Skip = true; return "no match"; } // | paragraphs=1-2 | files=1| Template:Bowerbirds | string tsrcall = Regex.Replace(tsramatch.Value, @"\s+", " ", RegexOptions.Singleline); string tsrstripped = Regex.Replace(tsrcall, @"{{Transclude list item excerpts as random slideshow([^}]*)}}", @"$1", RegexOptions.Singleline); string tsrnoparams = Regex.Replace(tsrstripped, @"\s*\|[^=\|]+=[^=\|]*\|", "|"); tsrnoparams = Regex.Replace(tsrnoparams, @"\s*\|[^=\|]+=[^=\|]*\|", "|"); tsrnoparams = Regex.Replace(tsrnoparams, @"\s*\|[^=\|]+=[^=\|]*\|", "|"); tsrnoparams = Regex.Replace(tsrnoparams, @"\s*\|[^=\|]+=[^=\|]*\|", "|"); tsrnoparams = Regex.Replace(tsrnoparams, @"\s*\|[^=\|]+=[^=\|]*\|", "|"); tsrnoparams = Regex.Replace(tsrnoparams, @"\s*\|[^=\|]+=[^=\|]*\|", "|"); tsrnoparams = Regex.Replace(tsrnoparams, @"\s*\|[^=\|]+=[^=\|]*\|", "|"); tsrnoparams = Regex.Replace(tsrnoparams, @"\s*\|\s*$", ""); tsrnoparams = Regex.Replace(tsrnoparams, @"\s*\|\s*$", ""); tsrnoparams = Regex.Replace(tsrnoparams, @"\s*\|\s*$", ""); Match onetemplate = Regex.Match(tsrnoparams, @"^\s*\|\s*Template:[^\|]+$"); if (!onetemplate.Success) { Skip = true; return "BAD!!!:::: " + tsrnoparams; } // Success return tsrnoparams; }