|
|
@@ -8,7 +8,6 @@ namespace Astralis {
|
|
|
/// Represents an HTML document that can be loaded, manipulated, and rendered
|
|
|
/// </summary>
|
|
|
public class MarkupDocument : GLib.Object {
|
|
|
- public bool fragment { get; private set; }
|
|
|
private Html.Doc* doc;
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -78,7 +77,6 @@ namespace Astralis {
|
|
|
}
|
|
|
|
|
|
var copied_doc = new MarkupDocument.from_doc((Html.Doc*)xml_copy);
|
|
|
- copied_doc.fragment = this.fragment;
|
|
|
return copied_doc;
|
|
|
}
|
|
|
|
|
|
@@ -91,15 +89,7 @@ namespace Astralis {
|
|
|
|
|
|
char[] buffer = html.to_utf8();
|
|
|
doc = Html.Doc.read_memory(buffer, buffer.length, "", null, options);
|
|
|
-
|
|
|
- if (doc == null) {
|
|
|
- // Try parsing as a fragment wrapped in a basic structure
|
|
|
- string wrapped = "<!DOCTYPE html><html><head><meta charset=\"UTF-8\"/></head><body>%s</body></html>".printf(html);
|
|
|
- char[] wrapped_buffer = wrapped.to_utf8();
|
|
|
- doc = Html.Doc.read_memory(wrapped_buffer, wrapped_buffer.length, "", null, options);
|
|
|
- fragment = true;
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
if (doc == null) {
|
|
|
throw new MarkupError.PARSE_ERROR("Failed to parse HTML document");
|
|
|
}
|
|
|
@@ -126,7 +116,6 @@ namespace Astralis {
|
|
|
/// </summary>
|
|
|
public MarkupNode? head {
|
|
|
owned get {
|
|
|
- if(fragment) return null;
|
|
|
var root = doc->get_root_element();
|
|
|
if (root == null) return null;
|
|
|
|
|
|
@@ -271,9 +260,6 @@ namespace Astralis {
|
|
|
/// Converts the document to an HTML string using libxml's HTML serializer
|
|
|
/// </summary>
|
|
|
public string to_html() {
|
|
|
- if(fragment) {
|
|
|
- return body.inner_html;
|
|
|
- }
|
|
|
string buffer;
|
|
|
int len;
|
|
|
doc->dump_memory(out buffer, out len);
|