public static GetTemplate ( string articleText, string template ) : string | ||
articleText | string | Source text |
template | string | Name of template, can be regex without a group capture |
return | string |
/// <summary> /// Extracts the persondata template from the articleText, along with the persondata comment, if present on the line before /// </summary> /// <param name="articleText">The wiki text of the article.</param> /// <returns></returns> public static string RemovePersonData(ref string articleText) { string strPersonData = (Variables.LangCode.Equals("de") ? Parsers.GetTemplate(articleText, "[Pp]ersonendaten") : Parsers.GetTemplate(articleText, "[Pp]ersondata")); if (!string.IsNullOrEmpty(strPersonData)) { articleText = articleText.Replace(strPersonData, ""); // detection of duplicate persondata template if (Variables.LangCode.Equals("en")) { string PersonData2 = Parsers.GetTemplate(articleText, "[Pp]ersondata"); if (!string.IsNullOrEmpty(PersonData2)) { articleText = articleText.Replace(PersonData2, ""); strPersonData += Tools.Newline(PersonData2); } } } // https://en.wikipedia.org/wiki/Wikipedia_talk:AutoWikiBrowser/Bugs/Archive_11#Persondata_comments // catch the persondata comment the line before it so that the comment and template aren't separated if (articleText.Contains(WikiRegexes.PersonDataCommentEN) && Variables.LangCode == "en") { articleText = articleText.Replace(WikiRegexes.PersonDataCommentEN, ""); strPersonData = WikiRegexes.PersonDataCommentEN + strPersonData; } return(strPersonData); }
/// <summary> /// /// </summary> /// <param name="articleText"></param> /// <returns></returns> public static string RemovePersonData(ref string articleText) { string strPersonData = (Variables.LangCode == LangCodeEnum.de) ? Parsers.GetTemplate(articleText, "[Pp]ersonendaten") : Parsers.GetTemplate(articleText, "[Pp]ersondata"); if (!string.IsNullOrEmpty(strPersonData)) { articleText = articleText.Replace(strPersonData, ""); } return(strPersonData); }
public static string removePersonData(ref string ArticleText) { string strPersonData; if (Variables.LangCode == LangCodeEnum.de) { strPersonData = Parsers.GetTemplate(ArticleText, "[Pp]ersonendaten"); } else { strPersonData = Parsers.GetTemplate(ArticleText, "[Pp]ersondata"); } if (!string.IsNullOrEmpty(strPersonData)) { ArticleText = ArticleText.Replace(strPersonData, ""); } return(strPersonData); }
/// <summary> /// Extracts the persondata template from the articleText, along with the persondata comment, if present on the line before /// </summary> /// <param name="articleText"></param> /// <returns></returns> public static string RemovePersonData(ref string articleText) { string strPersonData = (Variables.LangCode == LangCodeEnum.de) ? Parsers.GetTemplate(articleText, "[Pp]ersonendaten") : Parsers.GetTemplate(articleText, "[Pp]ersondata"); if (!string.IsNullOrEmpty(strPersonData)) { articleText = articleText.Replace(strPersonData, ""); } // http://en.wikipedia.org/wiki/Wikipedia_talk:AutoWikiBrowser/Bugs#Persondata_comments // catch the persondata comment the line before it so that the comment and template aren't separated if (articleText.Contains(WikiRegexes.PersonDataCommentEN) && Variables.LangCode == LangCodeEnum.en) { articleText = articleText.Replace(WikiRegexes.PersonDataCommentEN, ""); strPersonData = WikiRegexes.PersonDataCommentEN + strPersonData; } return(strPersonData); }