示例#1
0
        protected virtual string ModifyArticleName(string title)
        {
            WikiFunctions.Parse.Parsers p = new WikiFunctions.Parse.Parsers();

            title = p.Unicodify(title);

            title = title.Replace(@"&", "&");
            title = title.Replace(@""", @"""");
            return(title.Replace("<br />", ""));
        }
 protected virtual string ModifyArticleName(string title)
 {
     WikiFunctions.Parse.Parsers p = new WikiFunctions.Parse.Parsers();
     
     title = p.Unicodify(title);
     
     title = title.Replace(@"&amp;", "&");
     title = title.Replace(@"&quot;", @"""");
     return title.Replace("<br />", "");
 }
示例#3
0
        /// <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)
        {
            WikiFunctions.Parse.Parsers parsers = new WikiFunctions.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);
        }
示例#4
0
        /// <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)
        {
            WikiFunctions.Parse.Parsers parsers = new WikiFunctions.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;
        }