1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
const std = @import("std");
const Allocator = std.mem.Allocator;
pub const Kind = enum {
literal,
delimiter,
title,
quote,
code,
code_block,
math,
math_block,
image,
link,
bold,
italic,
ref,
callout,
list_ordored,
list_unordored,
tag,
};
gpa: Allocator,
kind: Kind,
content: std.ArrayList(u8),
const Self = @This();
pub fn init(gpa: Allocator, kind: Kind, content: std.ArrayList(u8)) Self {
return .{
.gpa = gpa,
.kind = kind,
.content = content,
};
}
pub fn deinit(self: *Self) void {
self.content.deinit(self.gpa);
}
pub fn clone(self: *const Self, gpa: Allocator) Allocator.Error!std.ArrayList(u8) {
return self.content.clone(gpa);
}
pub fn equals(self: *const Self, kind: Kind, content: []const u8) bool {
if (self.kind != kind) return false;
return std.mem.eql(u8, self.content.items, content);
}
|