User:Yobot/Error 59

////<summary>Removes <br> tags at the end of template parameter values. It works only for named parameters. CHECKWIKI error 59</summary>
// run through all templates in article
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
{
            Skip = false;
            Summary = "Removed break from end of template value";

  // for each template get all the named parameters
  foreach(Match m in WikiRegexes.NestedTemplates.Matches(ArticleText))
  {
    string template = m.Value;
    Dictionary<string, string> paramsFound = Tools.GetTemplateParameterValues(template);

    // assess each parameter in the template
    // remove <br> from end
    foreach(KeyValuePair<string,string> kp in paramsFound)
    {
      string paramvalue = kp.Value;
      paramvalue = Regex.Replace(paramvalue, @"( *< */? *[Bb][Rr] */? *> *)*$", "");
      // if <br> removed, update template parameter value in template call
      if(!paramvalue.Equals(kp.Value))
        template = Tools.SetTemplateParameterValue(template, kp.Key, paramvalue);
     }

     // if template changed, update article text
     if(!template.Equals(m.Value))
       ArticleText = ArticleText.Replace(m.Value, template);
  }
return ArticleText;
}