aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-04-29 18:10:33 +0200
committerAnhgelus Morhtuuzh <william@herges.fr>2026-04-29 18:10:33 +0200
commit0535fa152ae990a28d0b7b9a59e96911074118b8 (patch)
tree2b78936f147429da5b593174ee2e6cabbf9becbd /src
parent99d2408ad3113f3d79b496ed30798bbd15bc6cfc (diff)
build(zig): include typst module
Diffstat (limited to 'src')
-rw-r--r--src/root.zig1
-rw-r--r--src/typst.zig11
2 files changed, 12 insertions, 0 deletions
diff --git a/src/root.zig b/src/root.zig
index 6fd15f5..648fb77 100644
--- a/src/root.zig
+++ b/src/root.zig
@@ -2,6 +2,7 @@ const std = @import("std");
const builtin = @import("builtin");
const Allocator = std.mem.Allocator;
const parser = @import("parser.zig");
+const typst = @import("typst.zig");
pub const Document = parser.Document;
pub const Error = parser.Error;
/// Parse the content.
diff --git a/src/typst.zig b/src/typst.zig
new file mode 100644
index 0000000..9608af5
--- /dev/null
+++ b/src/typst.zig
@@ -0,0 +1,11 @@
+const std = @import("std");
+const typst = @cImport(@cInclude("typdown_typst.h"));
+
+pub fn generateSVG(alloc: std.mem.Allocator, content: []const u8) ![]const u8 {
+ const source = try alloc.dupeZ(u8, content);
+ defer alloc.free(source);
+ const raw_res = typst.typst_generateSVG(source);
+ const res = try alloc.dupe(u8, std.mem.span(raw_res));
+ defer typst.typst_freeString(raw_res);
+ return res;
+}