Пример #1
0
        public string Convert(string html)
        {
            var cleaner = new Cleaner();

            html = cleaner.PreTidy(html);

            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(html);

            var root = doc.DocumentNode;

            string result = this.Lookup(root.Name).Convert(root);

            return result;
        }
Пример #2
0
        public string Convert(string html)
        {
            var cleaner = new Cleaner();

            html = cleaner.PreTidy(html);

            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(html);

            var root = doc.DocumentNode;

            string result = this.Lookup(root.Name).Convert(root);

            return(result);
        }
        public string Convert(string html)
        {
            html = Cleaner.PreTidy(html, Config.RemoveComments);

            var doc = new HtmlDocument();

            doc.LoadHtml(html);

            var root = doc.DocumentNode;

            // ensure to start from body and ignore head etc
            if (root.Descendants("body").Any())
            {
                root = root.SelectSingleNode("//body");
            }

            var result = Lookup(root.Name).Convert(root);

            return(result);
        }
Пример #4
0
        public string Convert(string html)
        {
            html = Cleaner.PreTidy(html, Config.RemoveComments);

            var doc = new HtmlDocument();

            doc.LoadHtml(html);

            var root = doc.DocumentNode;

            // ensure to start from body and ignore head etc
            if (root.Descendants("body").Any())
            {
                root = root.SelectSingleNode("//body");
            }

            var result = Lookup(root.Name).Convert(root);

            // cleanup multiple new lines
            result = Regex.Replace(result, @"(^\p{Zs}*(\r\n|\n)){2,}", Environment.NewLine, RegexOptions.Multiline);

            return(result.Trim());
        }
        public string Convert(string html)
        {
            html = Cleaner.PreTidy(html, Config.RemoveComments);

            var doc = new HtmlDocument();

            doc.LoadHtml(html);

            var root = doc.DocumentNode;

            var body = root.SelectSingleNode("//body");

            if (body != null)
            {
                return(this.Lookup(body.Name).Convert(body));
            }

            string result = this.Lookup(root.Name).Convert(root);

            if (Config.CompressNewlines)
            {
                int oldlen = result.Length;
                while (true)
                {
                    result = result.Replace(_nlnlnl, _nlnl);
                    int newlen = result.Length;
                    if (newlen == oldlen)
                    {
                        break;
                    }
                    oldlen = newlen;
                }
            }

            return(result);
        }