https://github.com/chardoncs/zig-ansi-parse
Comptime-proof ANSI format parsing library for Zig
https://github.com/chardoncs/zig-ansi-parse
ansi-code ansi-colors ansi-terminal colorization parser zig ziglang
Last synced: 3 months ago
JSON representation
Comptime-proof ANSI format parsing library for Zig
- Host: GitHub
- URL: https://github.com/chardoncs/zig-ansi-parse
- Owner: chardoncs
- License: mit
- Created: 2024-10-31T06:17:49.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-01-05T03:42:55.000Z (5 months ago)
- Last Synced: 2025-02-23T10:42:27.120Z (3 months ago)
- Topics: ansi-code, ansi-colors, ansi-terminal, colorization, parser, zig, ziglang
- Language: Zig
- Homepage:
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# zig-ansi-parse
Comptime-proof ANSI format parsing library for Zig.
[How it works?](https://github.com/chardoncs/zig-ansi-parse/wiki/Syntax)
## Install
1. Fetch it in your project, `` is the version you want
```bash
zig fetch --save https://github.com/chardoncs/zig-ansi-parse/archive/refs/tags/v.tar.gz
```Or fetch the git repo for latest updates
```bash
zig fetch --save git+https://github.com/chardoncs/zig-ansi-parse
```2. Configure your `build.zig`.
```zig
const ansi_parse = b.dependency("ansi-parse", .{});
exe.root_module.addImport("ansi-parse", ansi_parse.module("ansi-parse"));
```## At a glance
```zig
const std = @import("std");
const parseComptime = @import("ansi-parse").parseComptime;const demo_text = parseComptime(
\\Greetings!> I'm bold> and blue>
\\Ignore this>
\\\
\\tabbedOllalHello
\\Three tabs
\\
, .{} // Options
);pub fn main() !void {
std.debug.print(demo_text, .{});
}
```## Options
| 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 |