const std = @import("std"); const mod = @import("root.zig"); const Attribute = mod.Attribute; const Tag = mod.Tag; pub const Element = union(enum) { const Self = @This(); tag: Tag, string: []const u8, pub fn node(name: []const u8, attributes: anytype, children: []const Element) Self { return .{ .tag = .tag(name, attributes, children) }; } pub fn @"void"(name: []const u8, attribute: anytype) Self { return .{ .tag = .void(name, attribute) }; } pub fn text(content: []const u8) Self { return .{ .string = content }; } pub fn format(self: *const Self, writer: *std.Io.Writer) !void { try switch (self.*) { .string => |content| writer.writeAll(content), .tag => |n| n.format(writer), }; } };