aboutsummaryrefslogtreecommitdiff
path: root/src/root.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/root.zig')
-rw-r--r--src/root.zig12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/root.zig b/src/root.zig
index 30386e9..5d8125f 100644
--- a/src/root.zig
+++ b/src/root.zig
@@ -53,7 +53,7 @@ const typdown_Document = extern struct {
const typdown_Error = extern struct {
code: u8,
- location: extern struct { beg: usize, end: usize },
+ location: extern struct { beg: usize, end: usize, line: usize },
};
};
@@ -65,7 +65,7 @@ fn from(alloc: Allocator, doc: Document) typdown_Document {
for (errors) |err| {
res.errors.?[0] = .{
.code = getErrorCode(err.err),
- .location = .{ .beg = err.location.beg, .end = err.location.end },
+ .location = .{ .beg = err.location.beg, .end = err.location.end, .line = err.location.line },
};
}
res.errors_len = errors.len;
@@ -75,7 +75,7 @@ fn from(alloc: Allocator, doc: Document) typdown_Document {
fn fromError(alloc: Allocator, err: Error) typdown_Document {
var v = alloc.alloc(typdown_Document.typdown_Error, 1) catch |e| @panic(@errorName(e));
- v[0] = .{ .code = getErrorCode(err), .location = .{ .beg = 0, .end = 0 } };
+ v[0] = .{ .code = getErrorCode(err), .location = .{ .beg = 0, .end = 0, .line = 0 } };
return .{ .errors = v.ptr, .errors_len = 1 };
}
@@ -108,8 +108,8 @@ export fn typdown_free(self: typdown_Document) void {
}
/// Render an HTML from the document.
-export fn typdown_renderHTML(document: typdown_Document, code: *u8) ?[*:0]const u8 {
- const root: *Element.Root = @ptrCast(@alignCast(document.root));
+export fn typdown_renderHTML(context: *anyopaque, code: *u8) ?[*:0]const u8 {
+ const root: *Element.Root = @ptrCast(@alignCast(context));
const res = root.renderHTML(default_alloc) catch |err| {
code.* = getErrorCode(err);
return null;
@@ -136,7 +136,7 @@ fn doTest(content: [*:0]const u8, exp: []const u8, comptime exp_code: u8) !void
return try expect(false);
}
var code: u8 = undefined;
- const raw = typdown_renderHTML(doc, &code) orelse {
+ const raw = typdown_renderHTML(doc.root, &code) orelse {
expect(code == exp_code) catch |err| {
std.debug.print("{}\n", .{code});
return err;