kick out the jams

Make the module act more like a module. The test code is now an
example. Get rid of redundant "Cmark" prefix in many types. Implement
most of the missing node routines.
This commit is contained in:
2023-09-09 23:45:22 -07:00
parent ce0c1ae97c
commit 3a73fbe312
3 changed files with 253 additions and 107 deletions

42
examples/render_html.zig Normal file
View File

@@ -0,0 +1,42 @@
const std = @import("std");
const cmark = @import("cmark");
pub fn main() !void {
const a = std.heap.page_allocator;
const parser = try cmark.Parser.init(&a, .{});
defer parser.deinit();
parser.feed(
\\##### Test
\\
\\This is a test of *commonmark* **parsing**
\\
\\-----
\\
\\ * `good`
\\ * [bye][@@@]
\\
\\```
\\farewell
\\```
\\
\\[@@@]: greetings (
\\ this is a long url title where I can put whatever I want on and on
\\ even over many lines
\\)
\\
);
const node = try parser.finish();
defer node.deinit();
const iterator = try node.iterator();
defer iterator.deinit();
while (iterator.next()) |visit| {
std.debug.print("{s} {s}\n", .{ @tagName(visit.event), @tagName(visit.node) });
}
std.debug.print("{s}\n", .{try node.render(.html, .{})});
}