/// <summary> /// /// </summary> /// <param name="tn"></param> /// <param name="text"></param> /// <param name="title"></param> /// <returns></returns> private static string ReplaceOn(TreeNode tn, string text, string title) { Rule r = (Rule)tn.Tag; if (!string.IsNullOrEmpty(r.replace_)) { string replace = Tools.ApplyKeyWords(title, r.replace_); string with = Tools.ApplyKeyWords(title, r.with_); if (!r.regex_) { replace = Regex.Escape(replace); } //stop \r\n being interpreted literally with = with.Replace(@"\r", "\r").Replace(@"\n", "\n"); text = Regex.Replace(text, replace, with, r.regexOptions_); } foreach (TreeNode t in tn.Nodes) { IRule sr = (IRule)t.Tag; text = sr.Apply(t, text, title); } return(text); }
private static string ReplaceOn(string template, TreeNode tn, string text, string title) { InTemplateRule r = (InTemplateRule)tn.Tag; foreach (TreeNode t in tn.Nodes) { IRule sr = (IRule)t.Tag; text = sr.Apply(t, text, title); } if (r.DoReplace_ && !string.IsNullOrEmpty(r.ReplaceWith_)) { if (string.IsNullOrEmpty(template)) { return(text); } string pattern = @"^([\s]*)" + Tools.CaseInsensitive(template) + @"([\s]*(?:<!--.*-->)?[\s]*(\}\}|\|))"; pattern = pattern.Replace(" ", "[ _]+"); text = Regex.Replace(text, pattern, "$1" + r.ReplaceWith_ + "$2"); } return(text); }
public string ApplyRules(string text, string title) { foreach (TreeNode tn in RulesTreeView.Nodes) { IRule r = (IRule)tn.Tag; text = r.Apply(tn, text, title); } return(text); }
public override string Apply(TreeNode tn, string text, string title) { if (string.IsNullOrEmpty(text)) { return(text); } if (!enabled_) { return(text); } string pattern = "(\\|[\\s]*)" + ParamName + "([\\s]*=)"; text = Regex.Replace(text, pattern, "$1" + NewParamName + "$2"); foreach (TreeNode t in tn.Nodes) { IRule sr = (IRule)t.Tag; text = sr.Apply(t, text, title); } return(text); }