public static Dictionary<int, int> BadCiteParameters(string articleText)
{
Dictionary<int, int> found = new Dictionary<int, int>();
// unknown parameters in cite arXiv, TemplateExists check for performance
if (TemplateExists(GetAllTemplates(articleText), CiteArXiv))
{
foreach (Match m in CiteArXiv.Matches(articleText))
{
// ignore parameters in templates within cite
string cite = @"{{" +
Tools.ReplaceWithSpaces(m.Value.Substring(2),
WikiRegexes.NestedTemplates.Matches(m.Value.Substring(2)));
foreach (Match m2 in CitationPopulatedParameter.Matches(cite))
{
if (!citeArXivParameters.IsMatch(m2.Groups[1].Value) &&
Tools.GetTemplateParameterValue(cite, m2.Groups[1].Value).Length > 0)
{
found.Add(m.Index + m2.Groups[1].Index, m2.Groups[1].Length);
}
}
}
}
foreach (Match m in WikiRegexes.CiteTemplate.Matches(articleText))
{
// unknown parameters in cite web
if (m.Groups[2].Value.EndsWith("web"))
{
// ignore parameters in templates within cite
string cite = @"{{" +
Tools.ReplaceWithSpaces(m.Value.Substring(2),
WikiRegexes.NestedTemplates.Matches(m.Value.Substring(2)));
foreach (Match m2 in CitationPopulatedParameter.Matches(cite))
{
if (!citeWebParameters.IsMatch(m2.Groups[1].Value) &&
Tools.GetTemplateParameterValue(cite, m2.Groups[1].Value).Length > 0)
{
found.Add(m.Index + m2.Groups[1].Index, m2.Groups[1].Length);
}
}
}
string pipecleaned = Tools.PipeCleanedTemplate(m.Value, false);
// no equals between two separator pipes
if (pipecleaned.Contains("="))
{
Match m2 = NoEqualsTwoBars.Match(pipecleaned);
if (m2.Success)
found.Add(m.Index + m2.Index, m2.Length);
}
// URL has space in it
int urlpos = m.Value.IndexOf("url");
if (urlpos > 0)
{
string URL = Tools.GetTemplateParameterValue(m.Value, "url");
if (URL.Contains(" ") &&
WikiRegexes.UnformattedText.Replace(WikiRegexes.NestedTemplates.Replace(URL, ""), "")
.Trim()
.Contains(" "))
{
// value of url may be in another earlier parameter, report correct position
string fromURL = m.Value.Substring(urlpos);
found.Add(m.Index + urlpos + fromURL.IndexOf(URL), URL.Length);
}
}
}
return found;
}