Beispiel #1
0
        private void Parse(string html)
        {
            Inlines.Clear();
            //html = HtmlToXamlConverter.ConvertHtmlToXaml(html, false);
            //try
            //{
            //    TextRange tr = new TextRange(ContentStart, ContentEnd);
            //    using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(html)))
            //    {
            //        tr.Load(ms, DataFormats.Xaml);
            //    }
            //}
            //catch
            //{
            //    throw new InvalidDataException("data provided is not in the correct Html format.");
            //}
            HtmlTagTree tree   = new HtmlTagTree();
            HtmlParser1 parser = new HtmlParser1(tree);  //output

            parser.Parse(new StringReader(html));        //input

            HtmlUpdater updater = new HtmlUpdater(this); //output

            updater.Update(tree);
        }
Beispiel #2
0
        private void Parse(string html)
        {
            if (!String.IsNullOrEmpty(Highlight))
            {
                int idx = html.IndexOf(Highlight, StringComparison.InvariantCultureIgnoreCase);
                while (idx != -1)
                {
                    html = String.Format("{0}[b]{1}[/b]{2}",
                                         html.Substring(0, idx), html.Substring(idx, Highlight.Length), html.Substring(idx + Highlight.Length));
                    idx = html.IndexOf(Highlight, idx + 7 + Highlight.Length, StringComparison.InvariantCultureIgnoreCase);
                }
            }

            Inlines.Clear();
            HtmlTagTree tree   = new HtmlTagTree();
            HtmlParser1 parser = new HtmlParser1(tree);  //output

            parser.Parse(new StringReader(html));        //input

            HtmlUpdater updater = new HtmlUpdater(this); //output

            updater.Update(tree);
        }