feature. See also
. The project being documented here (as the example) is the Zig library itself.
Document.Node
pub const Node = struct
File
Code
pub const Node = struct {
tag: Tag,
data: Data,
pub const Index = enum(u32) {
root = 0,
_,
};
pub const List = std.MultiArrayList(Node);
pub const Tag = enum {
root,
list,
list_item,
table,
table_row,
table_cell,
heading,
code_block,
blockquote,
paragraph,
thematic_break,
link,
autolink,
image,
strong,
emphasis,
code_span,
text,
line_break,
};
pub const Data = union {
none: void,
container: struct {
children: ExtraIndex,
},
text: struct {
content: StringIndex,
},
list: struct {
start: ListStart,
children: ExtraIndex,
},
list_item: struct {
tight: bool,
children: ExtraIndex,
},
table_cell: struct {
info: packed struct {
alignment: TableCellAlignment,
header: bool,
},
children: ExtraIndex,
},
heading: struct {
level: u3,
children: ExtraIndex,
},
code_block: struct {
tag: StringIndex,
content: StringIndex,
},
link: struct {
target: StringIndex,
children: ExtraIndex,
},
comptime {
// included for safety checks. Without such safety checks enabled,
// we always want this union to be 8 bytes.
if (builtin.mode != .debug and builtin.mode != .safe) {
assert(@sizeOf(Data) == 8);
}
}
};
pub const ListStart = enum(u30) {
// type can be more naturally expressed as ?u30. As it is, we want
// values to fit within 4 bytes, so ?u30 does not yet suffice for
// storage.
unordered = std.math.maxInt(u30),
_,
pub fn asNumber(start: ListStart) ?u30 {
if (start == .unordered) return null;
assert(@backingInt(start) <= 999_999_999);
return @backingInt(start);
}
};
pub const TableCellAlignment = enum(u2) {
unset,
left,
center,
right,
};
pub const Children = struct {
len: u32,
};
}