Update to latest master.

wch-ch32v003
Felix "xq" Queißner 3 years ago
parent 5cb8cf60e4
commit f1ca55f6c3

@ -3,12 +3,12 @@ const std = @import("std");
const pkgs = struct { const pkgs = struct {
const koino = std.build.Pkg{ const koino = std.build.Pkg{
.name = "koino", .name = "koino",
.path = "./deps/koino/src/koino.zig", .path = .{ .path = "./deps/koino/src/koino.zig" },
.dependencies = &[_]std.build.Pkg{ .dependencies = &[_]std.build.Pkg{
std.build.Pkg{ .name = "libpcre", .path = "deps/koino/vendor/libpcre.zig/src/main.zig" }, std.build.Pkg{ .name = "libpcre", .path = .{ .path = "deps/koino/vendor/libpcre.zig/src/main.zig" } },
std.build.Pkg{ .name = "htmlentities", .path = "deps/koino/vendor/htmlentities.zig/src/main.zig" }, std.build.Pkg{ .name = "htmlentities", .path = .{ .path = "deps/koino/vendor/htmlentities.zig/src/main.zig" } },
std.build.Pkg{ .name = "clap", .path = "deps/koino/vendor/zig-clap/clap.zig" }, std.build.Pkg{ .name = "clap", .path = .{ .path = "deps/koino/vendor/zig-clap/clap.zig" } },
std.build.Pkg{ .name = "zunicode", .path = "deps/koino/vendor/zunicode/src/zunicode.zig" }, std.build.Pkg{ .name = "zunicode", .path = .{ .path = "deps/koino/vendor/zunicode/src/zunicode.zig" } },
}, },
}; };
}; };

2
deps/koino vendored

@ -1 +1 @@
Subproject commit 0f243e26609be75fd4adb45653c6865a2fcb246e Subproject commit a3179c9316926f71582d8278af4e2f6f912cbc71

@ -33,7 +33,7 @@ pub fn main() anyerror!void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){}; var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit(); defer _ = gpa.deinit();
const allocator = &gpa.allocator; const allocator = gpa.allocator();
var website = Website{ var website = Website{
.allocator = allocator, .allocator = allocator,
@ -91,7 +91,7 @@ pub fn main() anyerror!void {
continue; continue;
} }
const path = try std.fs.path.join(&website.arena.allocator, &[_][]const u8{ const path = try std.fs.path.join(website.arena.allocator(), &[_][]const u8{
"website", "website",
"img", "img",
entry.name, entry.name,
@ -124,7 +124,7 @@ pub fn main() anyerror!void {
.date = date, .date = date,
}; };
article.src_file = try std.fs.path.join(&website.arena.allocator, &[_][]const u8{ article.src_file = try std.fs.path.join(website.arena.allocator(), &[_][]const u8{
"website", "website",
"articles", "articles",
entry.name, entry.name,
@ -185,6 +185,8 @@ const Date = struct {
} }
pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
_ = fmt;
_ = options;
try writer.print("{d:0>4}-{d:0>2}-{d:0>2}", .{ try writer.print("{d:0>4}-{d:0>2}-{d:0>2}", .{
self.year, self.month, self.day, self.year, self.month, self.day,
}); });
@ -206,7 +208,7 @@ const Website = struct {
const Self = @This(); const Self = @This();
is_prepared: bool = false, is_prepared: bool = false,
allocator: *std.mem.Allocator, allocator: std.mem.Allocator,
arena: std.heap.ArenaAllocator, arena: std.heap.ArenaAllocator,
articles: std.ArrayList(Article), articles: std.ArrayList(Article),
tutorials: std.ArrayList(Tutorial), tutorials: std.ArrayList(Tutorial),
@ -224,22 +226,22 @@ const Website = struct {
self.is_prepared = false; self.is_prepared = false;
try self.articles.append(Article{ try self.articles.append(Article{
.date = article.date, .date = article.date,
.src_file = try self.arena.allocator.dupe(u8, article.src_file), .src_file = try self.arena.allocator().dupe(u8, article.src_file),
.title = try self.arena.allocator.dupe(u8, article.title), .title = try self.arena.allocator().dupe(u8, article.title),
}); });
} }
fn addTutorial(self: *Self, tutorial: Tutorial) !void { fn addTutorial(self: *Self, tutorial: Tutorial) !void {
self.is_prepared = false; self.is_prepared = false;
try self.tutorials.append(Tutorial{ try self.tutorials.append(Tutorial{
.src_file = try self.arena.allocator.dupe(u8, tutorial.src_file), .src_file = try self.arena.allocator().dupe(u8, tutorial.src_file),
.title = try self.arena.allocator.dupe(u8, tutorial.title), .title = try self.arena.allocator().dupe(u8, tutorial.title),
}); });
} }
fn addImage(self: *Self, path: []const u8) !void { fn addImage(self: *Self, path: []const u8) !void {
self.is_prepared = false; self.is_prepared = false;
try self.images.append(try self.arena.allocator.dupe(u8, path)); try self.images.append(try self.arena.allocator().dupe(u8, path));
} }
fn findTitle(self: *Self, file: []const u8) !?[]const u8 { fn findTitle(self: *Self, file: []const u8) !?[]const u8 {
@ -268,13 +270,13 @@ const Website = struct {
} else null; } else null;
if (heading_or_null) |heading| { if (heading_or_null) |heading| {
var list = std.ArrayList(u8).init(&self.arena.allocator); var list = std.ArrayList(u8).init(self.arena.allocator());
defer list.deinit(); defer list.deinit();
var options = markdown_options; var options = markdown_options;
options.render.header_anchors = false; options.render.header_anchors = false;
try koino.html.print(list.writer(), &self.arena.allocator, options, heading); try koino.html.print(list.writer(), self.arena.allocator(), options, heading);
const string = list.toOwnedSlice(); const string = list.toOwnedSlice();
@ -306,6 +308,7 @@ const Website = struct {
} }
fn sortArticlesDesc(self: Self, lhs: Article, rhs: Article) bool { fn sortArticlesDesc(self: Self, lhs: Article, rhs: Article) bool {
_ = self;
if (lhs.date.lessThan(rhs.date)) if (lhs.date.lessThan(rhs.date))
return false; return false;
if (rhs.date.lessThan(lhs.date)) if (rhs.date.lessThan(lhs.date))
@ -319,7 +322,7 @@ const Website = struct {
} }
fn changeExtension(self: *Self, src_name: []const u8, new_ext: []const u8) ![]const u8 { fn changeExtension(self: *Self, src_name: []const u8, new_ext: []const u8) ![]const u8 {
return std.mem.join(&self.arena.allocator, "", &[_][]const u8{ return std.mem.join(self.arena.allocator(), "", &[_][]const u8{
removeExtension(src_name), removeExtension(src_name),
new_ext, new_ext,
}); });
@ -336,7 +339,7 @@ const Website = struct {
@as(usize, 1); @as(usize, 1);
} }
const buf = try self.arena.allocator.alloc(u8, len); const buf = try self.arena.allocator().alloc(u8, len);
var offset: usize = 0; var offset: usize = 0;
for (text) |c| { for (text) |c| {
if (std.mem.indexOfScalar(u8, legal_character, c) == null) { if (std.mem.indexOfScalar(u8, legal_character, c) == null) {
@ -406,7 +409,7 @@ const Website = struct {
std.debug.assert(self.is_prepared); std.debug.assert(self.is_prepared);
var doc: *koino.nodes.AstNode = blk: { var doc: *koino.nodes.AstNode = blk: {
var p = try koino.parser.Parser.init(&self.arena.allocator, markdown_options); var p = try koino.parser.Parser.init(self.arena.allocator(), markdown_options);
try p.feed(source); try p.feed(source);
defer p.deinit(); defer p.deinit();
break :blk try p.finish(); break :blk try p.finish();
@ -422,7 +425,7 @@ const Website = struct {
try self.renderHeader(writer); try self.renderHeader(writer);
{ {
var renderer = koino.html.makeHtmlFormatter(writer, &self.arena.allocator, markdown_options); var renderer = koino.html.makeHtmlFormatter(writer, self.arena.allocator(), markdown_options);
defer renderer.deinit(); defer renderer.deinit();
var iter = doc.first_child; var iter = doc.first_child;
@ -472,7 +475,7 @@ const Website = struct {
while (i) |c| : (i = c.next) { while (i) |c| : (i = c.next) {
try koino.html.print( try koino.html.print(
writer, writer,
&self.arena.allocator, self.arena.allocator(),
heading_options, heading_options,
c, c,
); );
@ -700,12 +703,12 @@ const Website = struct {
} }
} }
fn renderArticle(self: *Website, article: Article, dst_dir: std.fs.Dir, dst_name: []const u8) !void { // fn renderArticle(self: *Website, article: Article, dst_dir: std.fs.Dir, dst_name: []const u8) !void {
var formatter = HtmlFormatter.init(allocator, options); // var formatter = HtmlFormatter.init(allocator, options);
defer formatter.deinit(); // defer formatter.deinit();
try formatter.format(root, false); // try formatter.format(root, false);
return formatter.buffer.toOwnedSlice(); // return formatter.buffer.toOwnedSlice();
} // }
}; };

Loading…
Cancel
Save