예제 #1
0
 public static void Init(string Tag, string HTML, string HTMLClosure, bool AcceptParameters = false, bool TopMost = false, Func<BBCodeTag, BBTreeNode, string> Parser = null, bool SupressChildren = false, bool AllowNesting = false)
 {
     BBCodeTag New = new BBCodeTag()
     {
         Tag = Tag,
         HTML = HTML,
         HTMLClosure = HTMLClosure,
         AcceptParameters = AcceptParameters,
         Parser = Parser ?? HTMLEncodeTagParser,
         TopMost = TopMost,
         SupressChildren = SupressChildren,
         AllowNesting = AllowNesting
     };
     BBDict.Add(New.Tag.ToLowerInvariant(), New);
 }
예제 #2
0
 public BBTreeNode(string Data, BBCodeTag TagType)
 {
     Children = new List<BBTreeNode>();
     this.Data = Data;
     this.TagType = TagType;
 }
예제 #3
0
        static string UrlEncodeTagParser(BBCodeTag ToEncode, BBTreeNode NodeToParse)
        {
            string URL = NodeToParse.Data;
            if (String.IsNullOrEmpty(URL) && NodeToParse.Children.Count > 0)
            {
                URL = NodeToParse.Children[0].Data;
            }
            Regex Reg = new Regex(URLProtocolRegex);

            if (!Reg.IsMatch(URL, 0))
            {
                URL = "http://" + URL;
            }
            return String.Format(ToEncode.HTML, HttpUtility.HtmlAttributeEncode(HttpUtility.UrlPathEncode(URL)));
        }
예제 #4
0
 static string UrlEncodePartParser(BBCodeTag ToEncode, BBTreeNode NodeToParse)
 {
     string URL = NodeToParse.Data;
     if (String.IsNullOrEmpty(URL) && NodeToParse.Children.Count > 0)
         URL = NodeToParse.Children[0].Data;
     return String.Format(ToEncode.HTML, HttpUtility.HtmlAttributeEncode(HttpUtility.UrlPathEncode(URL)));
 }
예제 #5
0
 static string QuoteParser(BBCodeTag ToEncode, BBTreeNode NodeToParse)
 {
     string Name = "Quote";
     if (!String.IsNullOrWhiteSpace(NodeToParse.Data)) Name = HttpUtility.HtmlAttributeEncode(NodeToParse.Data);
     return String.Format(ToEncode.HTML, Name);
 }
예제 #6
0
 static string HTMLEncodeTagParser(BBCodeTag ToEncode, BBTreeNode NodeToParse)
 {
     if (!ToEncode.AcceptParameters) return ToEncode.HTML;
     return String.Format(ToEncode.HTML, HttpUtility.HtmlAttributeEncode(NodeToParse.Data));
 }
예제 #7
0
 static string CodeParser(BBCodeTag ToEncode, BBTreeNode NodeToParse)
 {
     StringBuilder Test = new StringBuilder();
     foreach (var Child in NodeToParse.Children)
         Test.Append(HttpUtility.HtmlEncode(Child.Data));
     var data = Test.Replace("\n", "</li><li>").Replace("\r", "").ToString();
     return String.Format(ToEncode.HTML, data);
 }