/// <summary> /// /// </summary> /// <param name="ArticleText">The text of the article</param> /// <param name="ArticleTitle">The title of the artlce</param> /// <param name="Regexes"></param> /// <param name="includeComment"></param> /// <returns></returns> public static string ExpandTemplate(string ArticleText, string ArticleTitle, Dictionary<Regex, string> Regexes, bool includeComment) { Parse.Parsers parsers = new Parse.Parsers(); foreach (KeyValuePair<Regex, string> p in Regexes) { MatchCollection uses = p.Key.Matches(ArticleText); foreach (Match m in uses) { string call = m.Value; string expandUri = Variables.URLLong + "api.php?action=expandtemplates&format=xml&title=" + Tools.WikiEncode(ArticleTitle) + "&text=" + HttpUtility.UrlEncode(call); string result; try { string respStr = Tools.GetHTML(expandUri); Match m1 = ExpandTemplatesRegex.Match(respStr); if (!m.Success) continue; result = HttpUtility.HtmlDecode(m1.Groups[1].Value); } catch { continue; } bool skipArticle; result = parsers.Unicodify(result, out skipArticle); if (includeComment) result = result + "<!-- " + call + " -->"; ArticleText = ArticleText.Replace(call, result); } } return ArticleText; }