コード例 #1
0
ファイル: HTMLParser.cs プロジェクト: humeaua/CVATools
        public static TextStyle.TextStyleCollection ParseHTML(ref string html, ref TextStyle defaultStyle)
        {
            TextStyle.TextStyleCollection tsc = new TextStyle.TextStyleCollection();
            string text = "<html>" + html + "</html>";

            XmlDocument xdf = new XmlDocument();

            xdf.LoadXml(text);

            foreach(XmlNode node in xdf.ChildNodes[0].ChildNodes)
            {
                ParseNode(node, ref defaultStyle, ref tsc);
            }

            return tsc;
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: humeaua/CVATools
        private void button1_Click(object sender, System.EventArgs e)
        {
            TextStyle.TextStyleCollection tsc;

            string input = textBox1.Text;

            try
            {
                input = HTMLParser.QuoteAttributes(ref input);

                TextStyle sTextStyle = new TextStyle();
                tsc = HTMLParser.ParseHTML(ref input, ref sTextStyle);
            }
            catch
            {
                TextStyle ts = new TextStyle();
                tsc = new TextStyle.TextStyleCollection();

                ts.Text = HTMLParser.RemoveHTMLTags(input);
                tsc.Add(ts);
            }

            textBox3.Text = "";

            foreach(TextStyle ts in tsc)
            {
                textBox3.Text += ts.ToString() + "\r\n\r\n";
            }
        }