|
@@ -57,6 +57,21 @@ namespace Astralis {
|
|
|
document.update(this);
|
|
document.update(this);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Gets all attributes of this element as a read-only dictionary
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ public ReadOnlyAssociative<string, string> get_attributes() {
|
|
|
|
|
+ var result = new Dictionary<string, string>();
|
|
|
|
|
+ for (var prop = xml_node->properties; prop != null; prop = prop->next) {
|
|
|
|
|
+ var name = prop->name;
|
|
|
|
|
+ var value = xml_node->get_prop(name);
|
|
|
|
|
+ if (name != null && value != null) {
|
|
|
|
|
+ result.set(name, value);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Gets the id attribute of this element
|
|
/// Gets the id attribute of this element
|
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -507,8 +522,7 @@ namespace Astralis {
|
|
|
Html.ParserOption.NOBLANKS |
|
|
Html.ParserOption.NOBLANKS |
|
|
|
Html.ParserOption.NONET);
|
|
Html.ParserOption.NONET);
|
|
|
|
|
|
|
|
- string wrapped = "<div>" + value + "</div>";
|
|
|
|
|
- char[] buffer = wrapped.to_utf8();
|
|
|
|
|
|
|
+ char[] buffer = value.to_utf8();
|
|
|
var temp_doc = Html.Doc.read_memory(buffer, buffer.length, "", "utf-8", options);
|
|
var temp_doc = Html.Doc.read_memory(buffer, buffer.length, "", "utf-8", options);
|
|
|
if (temp_doc == null) {
|
|
if (temp_doc == null) {
|
|
|
return;
|
|
return;
|
|
@@ -532,7 +546,7 @@ namespace Astralis {
|
|
|
owned get {
|
|
owned get {
|
|
|
// Use Html.Doc to serialize the children properly
|
|
// Use Html.Doc to serialize the children properly
|
|
|
var temp_doc = new Html.Doc();
|
|
var temp_doc = new Html.Doc();
|
|
|
- Xml.Node* wrapper = temp_doc.new_node(null, "div");
|
|
|
|
|
|
|
+ Xml.Node* wrapper = temp_doc.new_node(null, "html");
|
|
|
temp_doc.set_root_element(wrapper);
|
|
temp_doc.set_root_element(wrapper);
|
|
|
|
|
|
|
|
// Copy children to the wrapper
|
|
// Copy children to the wrapper
|
|
@@ -545,19 +559,8 @@ namespace Astralis {
|
|
|
string buffer;
|
|
string buffer;
|
|
|
int len;
|
|
int len;
|
|
|
temp_doc.dump_memory(out buffer, out len);
|
|
temp_doc.dump_memory(out buffer, out len);
|
|
|
-
|
|
|
|
|
- // Extract just the inner content (between <div> and </div>)
|
|
|
|
|
- // The HTML serializer outputs proper HTML without XML declaration
|
|
|
|
|
- string result = buffer ?? "";
|
|
|
|
|
-
|
|
|
|
|
- // Strip the wrapper div tags
|
|
|
|
|
- if (result.has_prefix("<div>")) {
|
|
|
|
|
- result = result.substring(5);
|
|
|
|
|
- }
|
|
|
|
|
- if (result.has_suffix("</div>")) {
|
|
|
|
|
- result = result.substring(0, result.length - 6);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ string result = buffer ?? "";
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|