Comptime-proof ANSI format parsing library for Zig.
- Fetch it in your project,
<version>
is the version you want
zig fetch --save https://github.com/chardoncs/zig-ansi-parse/archive/refs/tags/v<version>.tar.gz
Or fetch the git repo for latest updates
zig fetch --save git+https://github.com/chardoncs/zig-ansi-parse
- Configure your
build.zig
.
const ansi_parse = b.dependency("ansi-parse", .{});
exe.root_module.addImport("ansi-parse", ansi_parse.module("ansi-parse"));
const std = @import("std");
const parseComptime = @import("ansi-parse").parseComptime;
const demo_text = parseComptime(
\\<CYAN>Greetings!</> I'm <B>bold</> and <BLUE;B>blue</>
\\<NYAN>Ignore this</>
\\\<escaped>
\\<!TAB>tabbed<!LF>Ollal<!CR>Hello
\\<!TAB*3>Three tabs
\\
, .{} // Options
);
pub fn main() !void {
std.debug.print(demo_text, .{});
}
Name | Default value | Description |
---|---|---|
branch_quota | 200,000 | (Comptime only) Evaluation branch quota. A larger quota can prevent the compiler from giving up caused by loops |
out_size | input.len * 4 |
(Comptime only) Capacity of the output string, set a larger value if the output is truncated |