|
|
@@ -250,7 +250,7 @@ namespace Astralis {
|
|
|
public string to_html() {
|
|
|
string buffer;
|
|
|
doc->dump_memory(out buffer);
|
|
|
- return buffer;
|
|
|
+ return strip_xml_declaration(buffer);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -260,7 +260,23 @@ namespace Astralis {
|
|
|
string buffer;
|
|
|
int len;
|
|
|
doc->dump_memory_format(out buffer, out len, true);
|
|
|
- return buffer;
|
|
|
+ return strip_xml_declaration(buffer);
|
|
|
+ }
|
|
|
+
|
|
|
+ private string strip_xml_declaration(string html) {
|
|
|
+ // Remove XML declaration if present (e.g., <?xml version="1.0"?>)
|
|
|
+ if (html.has_prefix("<?xml")) {
|
|
|
+ int end = html.index_of("?>");
|
|
|
+ if (end >= 0) {
|
|
|
+ // Skip the declaration and any following whitespace/newline
|
|
|
+ int start = end + 2;
|
|
|
+ while (start < html.length && html[start].isspace()) {
|
|
|
+ start++;
|
|
|
+ }
|
|
|
+ return html.substring(start);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return html;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|