Beispiel #1
0
        public HTMLNode(IHtmlHtmlElement content)
        {
            Content = content;
            var bdElem = Content.QuerySelector("body")
                         .Cast <IHtmlBodyElement>();

            Body = new BodyNode(bdElem);
        }
Beispiel #2
0
        /// <summary>
        /// Converts HTML to "AMP HTML".
        /// </summary>
        /// <param name="htmlSource">HTML source code to be converted.</param>
        /// <exception cref="ArgumentNullException">When <paramref name="htmlSource"/> is null or empty string.</exception>
        /// <returns>Returns <see cref="ConvertionResult"/> which contains the result of the convertion.</returns>
        public ConvertionResult ConvertFromHtml(string htmlSource)
        {
            Guard.Requires(htmlSource, "htmlSource").IsNotNullOrEmpty();

            IHtmlDocument    document    = parser.Parse(htmlSource);
            IHtmlHtmlElement htmlElement = (IHtmlHtmlElement)document.DocumentElement;

            this.EnsureInitilized();

            ConvertFromHtmlElement(document, document.Body);

            return(new ConvertionResult {
                AmpHtml = document.Body.InnerHtml
            });
        }
Beispiel #3
0
        public string ConvertFromHtml(string htmlSource)
        {
            if (string.IsNullOrEmpty(htmlSource))
            {
                return(string.Empty);
            }

            IHtmlDocument    document    = new HtmlParser(this.angleSharpConfig).Parse(htmlSource);
            IHtmlHtmlElement htmlElement = (IHtmlHtmlElement)document.DocumentElement;

            this.EnsureInitilized();

            ConvertFromHtmlElement(document, document.Body);

            return(document.Body.InnerHtml);
        }