scoomboot/zig-markdown-parser
A fast, zero-copy markdown parser written in Zig that converts markdown to AST
A fast, zero-copy markdown parser written in Zig that converts markdown text into an Abstract Syntax Tree (AST).
⚠️ Early Development - This project is in the planning phase with comprehensive documentation but no parser implementation yet.
Clone the repository:
git clone https://github.com/[username]/zig-markdown-parser.git
cd zig-markdown-parser
# Build the project (both library and executable)
zig build
# Run the CLI executable
zig build run
# Run all tests
zig build test
# Build with specific optimization
zig build -Doptimize=ReleaseFast
zig build -Doptimize=ReleaseSafe
zig build -Doptimize=ReleaseSmall
zig build -Doptimize=Debug
const std = @import("std");
const markdown = @import("zig-markdown-parser");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const input = "# Hello, World!\n\nThis is a **markdown** document.";
const ast = try markdown.parse(allocator, input, .{});
defer ast.deinit(allocator);
// Traverse the AST for your purposes
// (HTML generation, analysis, transformation, etc.)
}
The parser follows a three-stage pipeline:
Input (string) → Lexer (tokens) → Parser (AST)
src/
├── main.zig # CLI entry point
├── root.zig # Library entry point
├── lexer.zig # Tokenization (planned)
├── parser.zig # AST construction (planned)
├── ast.zig # AST node definitions (planned)
├── token.zig # Token types (planned)
├── utils.zig # Shared utilities (planned)
└── errors.zig # Error handling (planned)
Paragraphs
Headers (H1-H6)
Lists (ordered/unordered)
Code blocks
Block quotes
Emphasis (bold/italic)
Links
Code spans
Images
Tables (GFM)
Nested structures
HTML blocks
Full specification compliance
Edge case handling
Comprehensive test suite
Benchmarking
Memory optimization
SIMD optimizations
Contributions are welcome! Please feel free to submit issues and pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.