internal Document(GumboDocumentNode node, GumboFactory factory) : base(node, null) { _children = factory.CreateLazy(() => ImmutableArray.CreateRange(node.GetChildren().OrderBy(x => x.index_within_parent).Select(x => factory.CreateNode(x, this)))); HasDocType = node.document.has_doctype; Name = NativeUtf8.StringFromNativeUtf8(node.document.name); PublicIdentifier = NativeUtf8.StringFromNativeUtf8(node.document.public_identifier); SystemIdentifier = NativeUtf8.StringFromNativeUtf8(node.document.system_identifier); DocTypeQuirksMode = node.document.doc_type_quirks_mode; }
public Gumbo(string html, GumboLibraryOptions?options = null) { _options = CreateOptions(options); _html = NativeUtf8.NativeUtf8FromString(html); _outputPtr = NativeMethods.gumbo_parse(_html); var output = Marshal.PtrToStructure <GumboOutput>(_outputPtr); _gumboDocumentNode = output.GetDocument(); Errors = output.GetErrors(); var lazyFactory = new LazyFactory(() => _disposed, typeof(Gumbo).Name); _gumboFactory = new GumboFactory(lazyFactory); Document = (Document)_gumboFactory.CreateNode(_gumboDocumentNode); }
public static XDocument ToXDocument(this GumboDocumentNode docNode) => (XDocument)CreateXNode(docNode);
public static IEnumerable <GumboNode> GetChildren(this GumboDocumentNode node) => MarshalToPtrArray(node.document.children).Select(MarshalToSpecificNode);