コード例 #1
0
ファイル: Program.cs プロジェクト: asmboom/htmlsharp
        static void Main(string[] args)
        {
            ParseTags();
            ParseAttributes();
            foreach (TagClass t in tags)
            {
                //Console.WriteLine(t.GetClassDefinition());
                //File.Delete(@"C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\HtmlSharp\HtmlSharp\Elements\" +
                //    new CultureInfo("en-US", false).TextInfo.ToTitleCase(t.Name) + ".cs");

                File.WriteAllText(@"..\..\..\HtmlSharp\Elements\Tags\" +
                                  TagClass.GetClassName(t.Name) + ".cs",
                                  t.GetClassDefinition());

                Console.WriteLine("{{\"{0}\", attributes => new {1}(attributes)}},", t.Name, TagClass.GetClassName(t.Name));
            }

            Console.WriteLine(tags.Count);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Nord001/htmlsharp
        static void ParseTags()
        {
            string html = File.ReadAllText("tags.html");
            foreach (Match match in tableRow.Matches(html))
            {
                string row = match.Groups[1].Value;
                List<string> infos = new List<string>();
                foreach (Match m in tableData.Matches(row))
                {
                    infos.Add(Clean(m.Value));
                }
                if (infos.Count > 0)
                {
                    TagClass t = new TagClass(infos[0]);
                    t.StartTagOptional = infos[1] == "O";
                    t.EndTagOptional = infos[2] == "O";

                    if (t.Name == "li")
                    {
                        t.NestingBreakers.AddRange(new[] { "ul", "ol" });
                    }
                    else if (t.Name == "dd" || t.Name == "dt")
                    {
                        t.NestingBreakers.Add("dl");
                    }
                    else if (t.Name == "tr")
                    {
                        t.NestingBreakers.AddRange(new[] { "table", "tbody", "tfoot", "thead" });
                    }
                    else if (t.Name == "td" || t.Name == "th")
                    {
                        t.NestingBreakers.Add("tr");
                    }
                    else if (t.Name == "thead" || t.Name == "tbody" || t.Name == "tfoot")
                    {
                        t.NestingBreakers.Add("table");
                    }

                    if (new[] { "address", "form", "p", "pre", "table", "tr", "td", "th", "thead", "tbody",
                        "tfoot", "ol", "ul", "li", "dl", "dd", "dt", "blockquote", "div", "fieldset", "ins",
                        "del", "noscript" }.Contains(t.Name))
                    {
                        t.ResetsNesting = true;
                    }

                    if (new[] { "table", "tr", "td", "th", "thead", "tbody",
                        "tfoot", "ol", "ul", "li", "dl", "dd", "dt", "blockquote", "div", "fieldset", "ins",
                        "del", "span", "font", "q", "object", "bdo", "sub", "sup", "center" }.Contains(t.Name))
                    {
                        t.AllowsNesting = true;
                    }

                    //self closing tags

                    if (new[] { "br", "hr", "input", "img", "meta", "spacer", "link", "frame", "base" }
                        .Contains(t.Name))
                    {
                        t.SelfClosing = true;
                    }

                    tags.Add(t);
                }
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: asmboom/htmlsharp
        static void ParseTags()
        {
            string html = File.ReadAllText("tags.html");

            foreach (Match match in tableRow.Matches(html))
            {
                string        row   = match.Groups[1].Value;
                List <string> infos = new List <string>();
                foreach (Match m in tableData.Matches(row))
                {
                    infos.Add(Clean(m.Value));
                }
                if (infos.Count > 0)
                {
                    TagClass t = new TagClass(infos[0]);
                    t.StartTagOptional = infos[1] == "O";
                    t.EndTagOptional   = infos[2] == "O";

                    if (t.Name == "li")
                    {
                        t.NestingBreakers.AddRange(new[] { "ul", "ol" });
                    }
                    else if (t.Name == "dd" || t.Name == "dt")
                    {
                        t.NestingBreakers.Add("dl");
                    }
                    else if (t.Name == "tr")
                    {
                        t.NestingBreakers.AddRange(new[] { "table", "tbody", "tfoot", "thead" });
                    }
                    else if (t.Name == "td" || t.Name == "th")
                    {
                        t.NestingBreakers.Add("tr");
                    }
                    else if (t.Name == "thead" || t.Name == "tbody" || t.Name == "tfoot")
                    {
                        t.NestingBreakers.Add("table");
                    }

                    if (new[] { "address", "form", "p", "pre", "table", "tr", "td", "th", "thead", "tbody",
                                "tfoot", "ol", "ul", "li", "dl", "dd", "dt", "blockquote", "div", "fieldset", "ins",
                                "del", "noscript" }.Contains(t.Name))
                    {
                        t.ResetsNesting = true;
                    }

                    if (new[] { "table", "tr", "td", "th", "thead", "tbody",
                                "tfoot", "ol", "ul", "li", "dl", "dd", "dt", "blockquote", "div", "fieldset", "ins",
                                "del", "span", "font", "q", "object", "bdo", "sub", "sup", "center" }.Contains(t.Name))
                    {
                        t.AllowsNesting = true;
                    }

                    //self closing tags

                    if (new[] { "br", "hr", "input", "img", "meta", "spacer", "link", "frame", "base" }
                        .Contains(t.Name))
                    {
                        t.SelfClosing = true;
                    }

                    tags.Add(t);
                }
            }
        }