Rename spec -> registry + type reading

This commit is contained in:
Robin Voetter
2020-01-22 21:03:03 +01:00
parent 9e3f2cc16a
commit 1d3f80c6a9
4 changed files with 523 additions and 345 deletions

View File

@@ -43,6 +43,18 @@ pub const Element = struct {
return null;
}
fn getCharData(self: *Element, child_tag: []const u8) ?[]const u8 {
const child = self.findChildByTag(child_tag) orelse return null;
if (child.children.count() != 1) {
return null;
}
return switch (child.children.at(0).*) {
.CharData => |char_data| char_data,
else => null
};
}
fn findChildByTag(self: *Element, tag: []const u8) ?*Element {
return self.findChildrenByTag(tag).next();
}