diff --git a/build.zig b/build.zig new file mode 100644 index 0000000..813d69f --- /dev/null +++ b/build.zig @@ -0,0 +1,44 @@ +const std = @import("std"); + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + + const exe = b.addExecutable(.{ + .name = "ziglue", + .root_source_file = b.path("src/main.zig"), + .target = target, + .optimize = optimize, + }); + + b.installArtifact(exe); + + const run_cmd = b.addRunArtifact(exe); + + run_cmd.step.dependOn(b.getInstallStep()); + + if (b.args) |args| { + run_cmd.addArgs(args); + } + + const run_step = b.step("run", "Run the app"); + run_step.dependOn(&run_cmd.step); + + const exe_unit_tests = b.addTest(.{ + .root_source_file = b.path("src/main.zig"), + .target = target, + .optimize = optimize, + }); + + const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests); + + const example_tests = b.addTest(.{ + .root_source_file = b.path("src/examples.zig"), + .target = target, + .optimize = optimize, + }); + + const test_step = b.step("test", "Run unit tests"); + test_step.dependOn(&run_exe_unit_tests.step); + test_step.dependOn(&example_tests.step); +} diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 0000000..23fe8b7 --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,10 @@ +.{ + .name = "ziglue", + .version = "0.0.0", + + .paths = .{ + "build.zig", + "build.zig.zon", + "src", + }, +} diff --git a/examples.py b/examples.py new file mode 100644 index 0000000..728439f --- /dev/null +++ b/examples.py @@ -0,0 +1,52 @@ +import parsel +import httpx +from pathlib import Path +from textwrap import indent + +VERSION = '0.31.2' + +CACHE = Path('.spec', VERSION) +URL = f'https://spec.commonmark.org/{VERSION}/' + +if CACHE.exists(): + sel = parsel.Selector(CACHE.read_text()) +else: + response = httpx.get('https://spec.commonmark.org/0.31.2/') + response.raise_for_status() + CACHE.parent.mkdir(parents=True, exist_ok=True) + CACHE.write_text(response.text) + sel = parsel.Selector(response.text) + +print( +'''const std = @import("std"); +const convert = @import("main.zig").convert; +''' +) + +for example in sel.css('.example'): + name = example.css('.examplenum > a::text').get() + md = example.css('.language-markdown::text').get() + html = example.css('.language-html::text').get() + + assert name is not None + + print(f''' +test "{name}" {{ + const alloc = std.testing.allocator; + + const md = ( +{indent(md, r' \\', lambda _: True) if md else '""'} +); + const html = ( +{indent(html, r' \\', lambda _: True) if html else '""'} +); + + const output = try convert(alloc, md); + defer alloc.free(output); + + try std.testing.expectEqualStrings(html, output); +}} +''') + + # mdtext = textwrap.indent("md", '\\') + diff --git a/notes.md b/notes.md new file mode 100644 index 0000000..89a6f8a --- /dev/null +++ b/notes.md @@ -0,0 +1,35 @@ +The spec is organized into "content blocks", "leaf blocks", and inline content. I should take this as a hint to do the same. + +So the first task in the parser should be to parse the block structure. + +- Blocks + - Leaf + - Thematic break + - ATX heading + - Setext heading + - Indented chunk + + Indented code block is a sequence of indented chunks. + + Preserve count of blank lines. + - Fenced code block + - HTML blocks + - Link reference definition + - Paragraph + - Blank lines + + These are part of the document, but they are not rendered. + - Container + - Blockquote + - List Item + + List is a sequence of list items of the same type. + +- Inline + - Inline code + - Strong, emph + - Links + - Inline + - Reference + - Images + - Auto + - HTML + - Text + + diff --git a/src/examples.zig b/src/examples.zig new file mode 100644 index 0000000..9fdfbdf --- /dev/null +++ b/src/examples.zig @@ -0,0 +1,11414 @@ +const std = @import("std"); +const convert = @import("main.zig").convert; + +comptime { + std.testing.refAllDecls(@This()); +} + +test "Example 1" { + return error.BBBBBBBBBBBBb; +} + +test "Example 2" { + const alloc = std.testing.allocator; + + const md = ( + \\→foo→baz→→bim + ); + const html = ( + \\
foo→baz→→bim
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 3" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\a→a
+ );
+ const html = (
+ \\a→a
+ \\ὐ→a
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 4" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\-
+ );
+ const html = (
+ \\foo
+ \\bar
+ \\foo
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 6" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\>→→foo
+ );
+ const html = (
+ \\
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 7" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\-→→foo
+ );
+ const html = (
+ \\
+ \\-
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 8" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\foo
+ \\→bar
+ );
+ const html = (
+ \\foo
+ \\bar
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 9" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\-
+ );
+ const html = (
+ \\
+ \\- foo
+ \\
+ \\- bar
+ \\
+ \\- baz
+ \\
+ \\
+ \\
+ \\
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 10" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\#→Foo
+ );
+ const html = (
+ \\Foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 11" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\*→*→*→
+ );
+ const html = (
+ \\
\?\@\[\\\]\^\_\`\{\|\}\~
+ );
+ const html = (
+ \\!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 13" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\\→\A\a\
+ );
+ const html = (
+ \\\→\A\a\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 14" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\\*not
+ );
+ const html = (
+ \\
*not
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 15" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\\\*emphasis*
+ );
+ const html = (
+ \\
\emphasis
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 16" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\foo\
+ \\bar
+ );
+ const html = (
+ \\foo
\[\`
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 18" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\\[\]
+ );
+ const html = (
+ \\\[\]
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 19" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\~~~
+ \\\[\]
+ \\~~~
+ );
+ const html = (
+ \\\[\]
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 20" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\
+ );
+ const html = (
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 26" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\#
+ );
+ const html = (
+ \\#
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 27" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\"
+ );
+ const html = (
+ \\
"
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 28" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\ 
+ );
+ const html = (
+ \\
 
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 29" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\©
+ );
+ const html = (
+ \\
©
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 30" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\&MadeUpEntity;
+ );
+ const html = (
+ \\&MadeUpEntity;
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 31" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\föö
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 36" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\föfö
+ );
+ const html = (
+ \\föfö
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 37" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\*foo*
+ \\*foo*
+ );
+ const html = (
+ \\*foo*
+ \\foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 38" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\*
+ );
+ const html = (
+ \\*
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 39" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\foo
bar
+ );
+ const html = (
+ \\
foo
+ \\
+ \\bar
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 40" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\ foo
+ );
+ const html = (
+ \\→foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 41" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\[a](url
+ );
+ const html = (
+ \\[a](url
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 42" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\-
+ );
+ const html = (
+ \\
+ \\- `one
+ \\- two`
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 43" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\***
+ \\---
+ \\___
+ );
+ const html = (
+ \\
+++
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 45" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\===
+ );
+ const html = (
+ \\===
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 46" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\--
+ \\**
+ \\__
+ );
+ const html = (
+ \\--
+ \\**
+ \\__
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 47" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\***
+ );
+ const html = (
+ \\
***
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 49" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\Foo
+ );
+ const html = (
+ \\Foo
+ \\***
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 50" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\_____________________________________
+ );
+ const html = (
+ \\
_
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 56" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\*-*
+ );
+ const html = (
+ \\-
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 57" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\-
+ );
+ const html = (
+ \\
+ \\- foo
+ \\
+ \\
Foo
+ \\
Foo
+ \\bar
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 60" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\*
+ );
+ const html = (
+ \\
+ \\- Foo
+ \\
+ \\
+ \\ - Foo
+ \\-
+ \\
foo
+ \\foo
+ \\foo
+ \\foo
+ \\foo
+ \\foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 63" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\#######
+ );
+ const html = (
+ \\#######
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 64" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\#5
+ );
+ const html = (
+ \\
#5
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 65" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\\##
+ );
+ const html = (
+ \\
##
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 66" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\#
+ );
+ const html = (
+ \\
foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 67" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\#
+ );
+ const html = (
+ \\foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 68" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\###
+ );
+ const html = (
+ \\foo
+ \\foo
+ \\foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 69" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\#
+ );
+ const html = (
+ \\#
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 70" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\foo
+ );
+ const html = (
+ \\foo
+ \\#
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 71" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\##
+ );
+ const html = (
+ \\
foo
+ \\bar
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 72" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\#
+ );
+ const html = (
+ \\foo
+ \\foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 73" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\###
+ );
+ const html = (
+ \\foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 74" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\###
+ );
+ const html = (
+ \\foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 75" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\#
+ );
+ const html = (
+ \\foo#
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 76" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\###
+ );
+ const html = (
+ \\foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 77" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\****
+ \\##
+ );
+ const html = (
+ \\
Foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 79" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\##
+ );
+ const html = (
+ \\
+ \\
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 80" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\Foo
+ );
+ const html = (
+ \\Foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 81" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\Foo
+ );
+ const html = (
+ \\Foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 82" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\Foo
+ );
+ const html = (
+ \\Foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 83" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\Foo
+ \\-------------------------
+ \\
+ \\Foo
+ \\=
+ );
+ const html = (
+ \\Foo
+ \\Foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 84" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\Foo
+ \\---
+ \\
+ );
+ const html = (
+ \\Foo
+ \\Foo
+ \\Foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 85" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\Foo
+ );
+ const html = (
+ \\Foo
+ \\---
+ \\
+ \\Foo
+ \\
+ \\
Foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 87" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\Foo
+ );
+ const html = (
+ \\
Foo
+ \\---
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 88" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\Foo
+ \\=
+ );
+ const html = (
+ \\Foo
+ \\=
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 89" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\Foo
+ );
+ const html = (
+ \\
Foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 90" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\Foo\
+ \\----
+ );
+ const html = (
+ \\Foo\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 91" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\`Foo
+ \\----
+ \\`
+ \\
+ \\`Foo
+ \\`
+ \\<a
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 92" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\>
+ );
+ const html = (
+ \\
+ \\Foo
+ \\
+ \\
+ );
+ const html = (
+ \\
+ \\foo
+ \\bar
+ \\===
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 94" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\-
+ );
+ const html = (
+ \\
+ \\- Foo
+ \\
+ \\
Foo
+ \\Bar
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 96" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\---
+ \\Foo
+ \\---
+ \\Bar
+ \\---
+ \\Baz
+ );
+ const html = (
+ \\
====
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 98" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\---
+ \\---
+ );
+ const html = (
+ \\
+ \\- foo
+ \\
+ \\
foo
+ \\
+ \\
+ );
+ const html = (
+ \\
+ \\foo
+ \\
+ \\
+ );
+ const html = (
+ \\>
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 103" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\Foo
+ \\
+ \\bar
+ \\---
+ \\baz
+ );
+ const html = (
+ \\
Foo
+ \\bar
+ \\baz
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 104" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\Foo
+ \\bar
+ \\
+ \\---
+ \\
+ \\baz
+ );
+ const html = (
+ \\Foo
+ \\bar
+ \\
Foo
+ \\bar
+ \\
Foo
+ \\bar
+ \\---
+ \\baz
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 107" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\a
+ );
+ const html = (
+ \\a
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 108" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\-
+ );
+ const html = (
+ \\
+ \\-
+ \\
foo
+ \\bar
+ \\
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 109" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\1.
+ );
+ const html = (
+ \\
+ \\-
+ \\
foo
+ \\
+ \\- bar
+ \\
+ \\
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 110" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\
+ );
+ const html = (
+ \\<a/>
+ \\*hi*
+ \\
+ \\-
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 111" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\chunk1
+ \\
+ );
+ const html = (
+ \\chunk1
+ \\
+ \\chunk2
+ \\
+ \\
+ \\
+ \\chunk3
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 112" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\chunk1
+ );
+ const html = (
+ \\chunk1
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 113" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\Foo
+ );
+ const html = (
+ \\Foo
+ \\bar
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 114" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\foo
+ \\bar
+ );
+ const html = (
+ \\foo
+ \\
+ \\bar
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 115" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\#
+ );
+ const html = (
+ \\Heading
+ \\foo
+ \\
+ \\Heading
+ \\foo
+ \\
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 117" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\
+ );
+ const html = (
+ \\foo
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 118" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\foo
+ );
+ const html = (
+ \\foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 119" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\```
+ \\<
+ );
+ const html = (
+ \\<
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 120" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\~~~
+ \\<
+ );
+ const html = (
+ \\<
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 121" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\``
+ \\foo
+ \\``
+ );
+ const html = (
+ \\foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 122" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\```
+ \\aaa
+ \\~~~
+ \\```
+ );
+ const html = (
+ \\aaa
+ \\~~~
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 123" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\~~~
+ \\aaa
+ \\```
+ \\~~~
+ );
+ const html = (
+ \\aaa
+ \\```
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 124" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\````
+ \\aaa
+ \\```
+ \\``````
+ );
+ const html = (
+ \\aaa
+ \\```
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 125" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\~~~~
+ \\aaa
+ \\~~~
+ \\~~~~
+ );
+ const html = (
+ \\aaa
+ \\~~~
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 126" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\```
+ );
+ const html = (
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 127" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\`````
+ \\
+ \\```
+ \\aaa
+ );
+ const html = (
+ \\
+ \\```
+ \\aaa
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 128" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\>
+ );
+ const html = (
+ \\
+ \\aaa
+ \\
+ \\
+ \\bbb
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 129" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\```
+ \\
+ );
+ const html = (
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 130" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\```
+ \\```
+ );
+ const html = (
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 131" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\```
+ );
+ const html = (
+ \\aaa
+ \\aaa
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 132" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\```
+ \\aaa
+ );
+ const html = (
+ \\aaa
+ \\aaa
+ \\aaa
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 133" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\```
+ );
+ const html = (
+ \\aaa
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 134" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\```
+ );
+ const html = (
+ \\```
+ \\aaa
+ \\```
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 135" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\```
+ \\aaa
+ );
+ const html = (
+ \\aaa
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 136" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\```
+ \\aaa
+ );
+ const html = (
+ \\aaa
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 137" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\```
+ \\aaa
+ );
+ const html = (
+ \\aaa
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 138" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\```
+ );
+ const html = (
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 139" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\~~~~~~
+ \\aaa
+ \\~~~
+ );
+ const html = (
+ \\aaa
+ \\~~~
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 140" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\foo
+ \\```
+ \\bar
+ \\```
+ \\baz
+ );
+ const html = (
+ \\foo
+ \\bar
+ \\
+ \\baz
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 141" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\foo
+ \\---
+ \\~~~
+ \\bar
+ \\~~~
+ \\#
+ );
+ const html = (
+ \\foo
+ \\bar
+ \\
+ \\baz
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 142" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\```ruby
+ \\def
+ );
+ const html = (
+ \\aa
+ \\foo
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 146" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\~~~
+ );
+ const html = (
+ \\```
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 148" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\
+ \\
+ \\**Hello**,
+ \\
+ \\_world_.
+ \\
+ \\
+ );
+ const html = (
+ \\
+ \\
+ \\**Hello**,
+ \\world.
+ \\
+ \\
+ );
+
+ const output = try convert(alloc, md);
+ defer alloc.free(output);
+
+ try std.testing.expectEqualStrings(html, output);
+}
+
+test "Example 149" {
+ const alloc = std.testing.allocator;
+
+ const md = (
+ \\