public static document createFromUTF8(string str, Icontainer container, script_engine script, context ctx, css user_styles = null) { var doc = new document(container, script, ctx); // Create litehtml::document var root_elements = new List <element>(); using (var gumbo = new Gumbo.Gumbo(str)) // parse document into GumboOutput doc.create_node(gumbo.Document.Root, root_elements, true); // Create litehtml::elements. if (root_elements.Count != 0) { doc._root = root_elements.Back(); } // Let's process created elements tree if (doc._root != null) { doc.container.get_media_features(doc._media); doc._root.apply_stylesheet(ctx.master_css); // apply master CSS doc._root.parse_attributes(); // parse elements attributes foreach (var css in doc._css) // parse style sheets linked in document { doc._styles.parse_stylesheet(css.text, css.baseurl, doc, !string.IsNullOrEmpty(css.media) ? media_query_list.create_from_string(css.media, doc) : null); } doc._styles.sort_selectors(); // Sort css selectors using CSS rules. if (doc._media_lists.Count != 0) { doc.update_media_lists(doc._media); // get current media features } doc._root.apply_stylesheet(doc._styles); // Apply parsed styles. if (user_styles != null) { doc._root.apply_stylesheet(user_styles); // Apply user styles if any } doc._root.parse_styles(); // Parse applied styles in the elements doc.fix_tables_layout(); // Now the _tabular_elements is filled with tabular elements. We have to check the tabular elements for missing table elements and create the anonymous boxes in visual table layout doc._root.init(); // Fanaly initialize elements } return(doc); }
public document(Icontainer container, script_engine script, context ctx) : base() { _container = container; _script = script; _context = ctx; }
public static document createFromString(string str, Icontainer container, script_engine script, context ctx, css user_styles = null) => createFromUTF8(Encoding.UTF8.GetString(Encoding.Default.GetBytes(str)), container, script, ctx, user_styles);