diff --git a/ziglue/.envrc b/ziglue/.envrc
new file mode 100644
index 0000000..08f9db7
--- /dev/null
+++ b/ziglue/.envrc
@@ -0,0 +1,3 @@
+PATH_add zig-out/bin
+source .venv/bin/activate
+
diff --git a/ziglue/.gitignore b/ziglue/.gitignore
new file mode 100644
index 0000000..e73c22a
--- /dev/null
+++ b/ziglue/.gitignore
@@ -0,0 +1,5 @@
+.zig-cache/
+zig-out/
+
+.spec/
+
diff --git a/ziglue/.tool-versions b/ziglue/.tool-versions
new file mode 100644
index 0000000..f81adbc
--- /dev/null
+++ b/ziglue/.tool-versions
@@ -0,0 +1 @@
+zig master
diff --git a/ziglue/README.md b/ziglue/README.md
new file mode 100644
index 0000000..e69de29
diff --git a/ziglue/build.zig b/ziglue/build.zig
new file mode 100644
index 0000000..271bf91
--- /dev/null
+++ b/ziglue/build.zig
@@ -0,0 +1,46 @@
+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 run_example_tests = b.addRunArtifact(example_tests);
+
+ const test_step = b.step("test", "Run unit tests");
+ test_step.dependOn(&run_exe_unit_tests.step);
+ test_step.dependOn(&run_example_tests.step);
+}
diff --git a/ziglue/build.zig.zon b/ziglue/build.zig.zon
new file mode 100644
index 0000000..23fe8b7
--- /dev/null
+++ b/ziglue/build.zig.zon
@@ -0,0 +1,10 @@
+.{
+ .name = "ziglue",
+ .version = "0.0.0",
+
+ .paths = .{
+ "build.zig",
+ "build.zig.zon",
+ "src",
+ },
+}
diff --git a/ziglue/examples.py b/ziglue/examples.py
new file mode 100644
index 0000000..b1bc98a
--- /dev/null
+++ b/ziglue/examples.py
@@ -0,0 +1,61 @@
+import parsel
+import httpx
+from pathlib import Path
+from textwrap import indent
+from subprocess import Popen, PIPE
+
+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)
+
+
+formatter = Popen(['zig', 'fmt', '--stdin'], stdin=PIPE, encoding='utf-8')
+assert formatter.stdin
+
+write = formatter.stdin.write
+
+write(f'''
+ //! Example cases from Commonmark spec {VERSION}
+ //! {URL}
+
+ const std = @import("std");
+ const convert = @import("main.zig").convert;
+''')
+
+for example in sel.css('.example'):
+ name = example.css('.examplenum > a::text').get()
+
+ md = ''.join(example.css('.language-markdown *::text').getall())
+ html = ''.join(example.css('.language-html *::text').getall())
+
+ md = md.replace('→', ' ')
+ html = html.replace('→', ' ')
+
+ assert name is not None
+
+ write(f'''
+ test "{name}" {{
+ const output = try convert(std.testing.allocator,
+ {indent(md, r'\\', lambda _: True) if md else '""'}
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ {indent(html, r'\\', lambda _: True) if html else '""'}
+ ,
+ output
+ );
+ }}
+ ''')
+
+formatter.stdin.close()
diff --git a/ziglue/notes.md b/ziglue/notes.md
new file mode 100644
index 0000000..a4de5b6
--- /dev/null
+++ b/ziglue/notes.md
@@ -0,0 +1,37 @@
+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.
+
+
foo baz bim
+ \\
+ , output);
+}
+
+test "Example 2" {
+ const output = try convert(std.testing.allocator,
+ \\ foo baz bim
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\foo baz bim
+ \\
+ , output);
+}
+
+test "Example 3" {
+ const output = try convert(std.testing.allocator,
+ \\ a a
+ \\ ὐ a
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\a a
+ \\ὐ a
+ \\
+ , output);
+}
+
+test "Example 4" {
+ const output = try convert(std.testing.allocator,
+ \\ - foo
+ \\
+ \\ bar
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\foo
+ \\bar
+ \\foo
+ \\ bar
+ \\
+ \\+ \\+ , output); +} + +test "Example 7" { + const output = try convert(std.testing.allocator, + \\- foo + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\+ \\foo + \\
foo
+ \\
+ \\foo
+ \\bar
+ \\
+ , output);
+}
+
+test "Example 9" {
+ const output = try convert(std.testing.allocator,
+ \\ - foo
+ \\ - bar
+ \\ - baz
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
+ , output); +} + +test "Example 13" { + const output = try convert(std.testing.allocator, + \\\ \A\a\ \3\φ\« + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\\ \A\a\ \3\φ\«
+ , output); +} + +test "Example 14" { + const output = try convert(std.testing.allocator, + \\\*not emphasized* + \\\*not emphasized* + \\<br/> not a tag + \\[not a link](/foo) + \\`not code` + \\1. not a list + \\* not a list + \\# not a heading + \\[foo]: /url "not a reference" + \\ö not a character entity
+ , output); +} + +test "Example 15" { + const output = try convert(std.testing.allocator, + \\\\*emphasis* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\\emphasis
+ , output); +} + +test "Example 16" { + const output = try convert(std.testing.allocator, + \\foo\ + \\bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ \\bar
\[\`
\[\]
+ \\
+ , output);
+}
+
+test "Example 19" {
+ const output = try convert(std.testing.allocator,
+ \\~~~
+ \\\[\]
+ \\~~~
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\\[\]
+ \\
+ , output);
+}
+
+test "Example 20" {
+ const output = try convert(std.testing.allocator,
+ \\foo
+ \\
+ , output);
+}
+
+test "Example 25" {
+ const output = try convert(std.testing.allocator,
+ \\ & © Æ Ď
+ \\¾ ℋ ⅆ
+ \\∲ ≧̸
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\& © Æ Ď + \\¾ ℋ ⅆ + \\∲ ≧̸
+ , output); +} + +test "Example 26" { + const output = try convert(std.testing.allocator, + \\# Ӓ Ϡ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\# Ӓ Ϡ �
+ , output); +} + +test "Example 27" { + const output = try convert(std.testing.allocator, + \\" ആ ಫ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\" ആ ಫ
+ , output); +} + +test "Example 28" { + const output = try convert(std.testing.allocator, + \\  &x; + \\ + \\abcdef0; + \\&ThisIsNotDefined; &hi?; + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\  &x; &#; &#x; + \\� + \\&#abcdef0; + \\&ThisIsNotDefined; &hi?;
+ , output); +} + +test "Example 29" { + const output = try convert(std.testing.allocator, + \\© + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\©
+ , output); +} + +test "Example 30" { + const output = try convert(std.testing.allocator, + \\&MadeUpEntity; + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\&MadeUpEntity;
+ , output); +} + +test "Example 31" { + const output = try convert(std.testing.allocator, + \\ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 32" { + const output = try convert(std.testing.allocator, + \\[foo](/föö "föö") + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 33" { + const output = try convert(std.testing.allocator, + \\[foo] + \\ + \\[foo]: /föö "föö" + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 34" { + const output = try convert(std.testing.allocator, + \\``` föö + \\foo + \\``` + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ \\
+ , output);
+}
+
+test "Example 35" {
+ const output = try convert(std.testing.allocator,
+ \\`föö`
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\föö
föfö
+ \\
+ , output);
+}
+
+test "Example 37" {
+ const output = try convert(std.testing.allocator,
+ \\*foo*
+ \\*foo*
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\*foo* + \\foo
+ , output); +} + +test "Example 38" { + const output = try convert(std.testing.allocator, + \\* foo + \\ + \\* foo + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\* foo
+ \\foo + \\ + \\bar
+ , output); +} + +test "Example 40" { + const output = try convert(std.testing.allocator, + \\ foo + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ , output); +} + +test "Example 41" { + const output = try convert(std.testing.allocator, + \\[a](url "tit") + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[a](url "tit")
+ , output); +} + +test "Example 42" { + const output = try convert(std.testing.allocator, + \\- `one + \\- two` + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\+++
+ , output); +} + +test "Example 45" { + const output = try convert(std.testing.allocator, + \\=== + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\===
+ , output); +} + +test "Example 46" { + const output = try convert(std.testing.allocator, + \\-- + \\** + \\__ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\-- + \\** + \\__
+ , output); +} + +test "Example 47" { + const output = try convert(std.testing.allocator, + \\ *** + \\ *** + \\ *** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\***
+ \\
+ , output);
+}
+
+test "Example 49" {
+ const output = try convert(std.testing.allocator,
+ \\Foo
+ \\ ***
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\Foo + \\***
+ , output); +} + +test "Example 50" { + const output = try convert(std.testing.allocator, + \\_____________________________________ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\_ _ _ _ a
+ \\a------
+ \\---a---
+ , output); +} + +test "Example 56" { + const output = try convert(std.testing.allocator, + \\ *-* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\-
+ , output); +} + +test "Example 57" { + const output = try convert(std.testing.allocator, + \\- foo + \\*** + \\- bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\Foo
+ \\bar
+ , output); +} + +test "Example 59" { + const output = try convert(std.testing.allocator, + \\Foo + \\--- + \\bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\bar
+ , output); +} + +test "Example 60" { + const output = try convert(std.testing.allocator, + \\* Foo + \\* * * + \\* Bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\####### foo
+ , output); +} + +test "Example 64" { + const output = try convert(std.testing.allocator, + \\#5 bolt + \\ + \\#hashtag + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\#5 bolt
+ \\#hashtag
+ , output); +} + +test "Example 65" { + const output = try convert(std.testing.allocator, + \\\## foo + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\## foo
+ , output); +} + +test "Example 66" { + const output = try convert(std.testing.allocator, + \\# foo *bar* \*baz\* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\# foo
+ \\
+ , output);
+}
+
+test "Example 70" {
+ const output = try convert(std.testing.allocator,
+ \\foo
+ \\ # bar
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\foo + \\# bar
+ , output); +} + +test "Example 71" { + const output = try convert(std.testing.allocator, + \\## foo ## + \\ ### bar ### + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\Foo bar
+ \\Bar foo
+ , output); +} + +test "Example 79" { + const output = try convert(std.testing.allocator, + \\## + \\# + \\### ### + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + \\ + \\ + , output); +} + +test "Example 80" { + const output = try convert(std.testing.allocator, + \\Foo *bar* + \\========= + \\ + \\Foo *bar* + \\--------- + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\Foo
+ \\---
+ \\
+ \\Foo
+ \\
+ \\Foo + \\---
+ , output); +} + +test "Example 88" { + const output = try convert(std.testing.allocator, + \\Foo + \\= = + \\ + \\Foo + \\--- - + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\Foo + \\= =
+ \\Foo
+ \\`
+ \\of dashes"/>
+ , output); +} + +test "Example 92" { + const output = try convert(std.testing.allocator, + \\> Foo + \\--- + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\+ \\+ \\Foo
+ \\
+ \\+ , output); +} + +test "Example 94" { + const output = try convert(std.testing.allocator, + \\- Foo + \\--- + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo + \\bar + \\===
+ \\
Baz
+ , output); +} + +test "Example 97" { + const output = try convert(std.testing.allocator, + \\ + \\==== + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\====
+ , output); +} + +test "Example 98" { + const output = try convert(std.testing.allocator, + \\--- + \\--- + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ \\
+ \\+ \\+ \\foo
+ \\
Foo
+ \\baz
+ , output); +} + +test "Example 104" { + const output = try convert(std.testing.allocator, + \\Foo + \\bar + \\ + \\--- + \\ + \\baz + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\Foo + \\bar
+ \\baz
+ , output); +} + +test "Example 105" { + const output = try convert(std.testing.allocator, + \\Foo + \\bar + \\* * * + \\baz + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\Foo + \\bar
+ \\baz
+ , output); +} + +test "Example 106" { + const output = try convert(std.testing.allocator, + \\Foo + \\bar + \\\--- + \\baz + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\Foo + \\bar + \\--- + \\baz
+ , output); +} + +test "Example 107" { + const output = try convert(std.testing.allocator, + \\ a simple + \\ indented code block + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\a simple
+ \\ indented code block
+ \\
+ , output);
+}
+
+test "Example 108" {
+ const output = try convert(std.testing.allocator,
+ \\ - foo
+ \\
+ \\ bar
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\foo
+ \\bar
+ \\foo
+ \\<a/>
+ \\*hi*
+ \\
+ \\- one
+ \\
+ , output);
+}
+
+test "Example 111" {
+ const output = try convert(std.testing.allocator,
+ \\ chunk1
+ \\
+ \\ chunk2
+ \\
+ \\
+ \\
+ \\ chunk3
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\chunk1
+ \\
+ \\chunk2
+ \\
+ \\
+ \\
+ \\chunk3
+ \\
+ , output);
+}
+
+test "Example 112" {
+ const output = try convert(std.testing.allocator,
+ \\ chunk1
+ \\
+ \\ chunk2
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\chunk1
+ \\
+ \\ chunk2
+ \\
+ , output);
+}
+
+test "Example 113" {
+ const output = try convert(std.testing.allocator,
+ \\Foo
+ \\ bar
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\Foo + \\bar
+ , output); +} + +test "Example 114" { + const output = try convert(std.testing.allocator, + \\ foo + \\bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ \\
+ \\bar
+ , output); +} + +test "Example 115" { + const output = try convert(std.testing.allocator, + \\# Heading + \\ foo + \\Heading + \\------ + \\ foo + \\---- + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ \\
+ \\foo
+ \\
+ \\ foo
+ \\bar
+ \\
+ , output);
+}
+
+test "Example 117" {
+ const output = try convert(std.testing.allocator,
+ \\
+ \\
+ \\ foo
+ \\
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\foo
+ \\
+ , output);
+}
+
+test "Example 118" {
+ const output = try convert(std.testing.allocator,
+ \\ foo
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\foo
+ \\
+ , output);
+}
+
+test "Example 119" {
+ const output = try convert(std.testing.allocator,
+ \\```
+ \\<
+ \\ >
+ \\```
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\<
+ \\ >
+ \\
+ , output);
+}
+
+test "Example 120" {
+ const output = try convert(std.testing.allocator,
+ \\~~~
+ \\<
+ \\ >
+ \\~~~
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\<
+ \\ >
+ \\
+ , output);
+}
+
+test "Example 121" {
+ const output = try convert(std.testing.allocator,
+ \\``
+ \\foo
+ \\``
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\foo
aaa
+ \\~~~
+ \\
+ , output);
+}
+
+test "Example 123" {
+ const output = try convert(std.testing.allocator,
+ \\~~~
+ \\aaa
+ \\```
+ \\~~~
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\aaa
+ \\```
+ \\
+ , output);
+}
+
+test "Example 124" {
+ const output = try convert(std.testing.allocator,
+ \\````
+ \\aaa
+ \\```
+ \\``````
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\aaa
+ \\```
+ \\
+ , output);
+}
+
+test "Example 125" {
+ const output = try convert(std.testing.allocator,
+ \\~~~~
+ \\aaa
+ \\~~~
+ \\~~~~
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\aaa
+ \\~~~
+ \\
+ , output);
+}
+
+test "Example 126" {
+ const output = try convert(std.testing.allocator,
+ \\```
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\
+ , output);
+}
+
+test "Example 127" {
+ const output = try convert(std.testing.allocator,
+ \\`````
+ \\
+ \\```
+ \\aaa
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\
+ \\```
+ \\aaa
+ \\
+ , output);
+}
+
+test "Example 128" {
+ const output = try convert(std.testing.allocator,
+ \\> ```
+ \\> aaa
+ \\
+ \\bbb
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\+ \\+ \\+ \\aaa + \\
bbb
+ , output); +} + +test "Example 129" { + const output = try convert(std.testing.allocator, + \\``` + \\ + \\ + \\``` + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\
+ \\
+ \\
+ , output);
+}
+
+test "Example 130" {
+ const output = try convert(std.testing.allocator,
+ \\```
+ \\```
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\
+ , output);
+}
+
+test "Example 131" {
+ const output = try convert(std.testing.allocator,
+ \\ ```
+ \\ aaa
+ \\aaa
+ \\```
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\aaa
+ \\aaa
+ \\
+ , output);
+}
+
+test "Example 132" {
+ const output = try convert(std.testing.allocator,
+ \\ ```
+ \\aaa
+ \\ aaa
+ \\aaa
+ \\ ```
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\aaa
+ \\aaa
+ \\aaa
+ \\
+ , output);
+}
+
+test "Example 133" {
+ const output = try convert(std.testing.allocator,
+ \\ ```
+ \\ aaa
+ \\ aaa
+ \\ aaa
+ \\ ```
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\aaa
+ \\ aaa
+ \\aaa
+ \\
+ , output);
+}
+
+test "Example 134" {
+ const output = try convert(std.testing.allocator,
+ \\ ```
+ \\ aaa
+ \\ ```
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\```
+ \\aaa
+ \\```
+ \\
+ , output);
+}
+
+test "Example 135" {
+ const output = try convert(std.testing.allocator,
+ \\```
+ \\aaa
+ \\ ```
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\aaa
+ \\
+ , output);
+}
+
+test "Example 136" {
+ const output = try convert(std.testing.allocator,
+ \\ ```
+ \\aaa
+ \\ ```
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\aaa
+ \\
+ , output);
+}
+
+test "Example 137" {
+ const output = try convert(std.testing.allocator,
+ \\```
+ \\aaa
+ \\ ```
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\aaa
+ \\ ```
+ \\
+ , output);
+}
+
+test "Example 138" {
+ const output = try convert(std.testing.allocator,
+ \\``` ```
+ \\aaa
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\
+ \\aaa
aaa
+ \\~~~ ~~
+ \\
+ , output);
+}
+
+test "Example 140" {
+ const output = try convert(std.testing.allocator,
+ \\foo
+ \\```
+ \\bar
+ \\```
+ \\baz
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\foo
+ \\bar
+ \\
+ \\baz
+ , output); +} + +test "Example 141" { + const output = try convert(std.testing.allocator, + \\foo + \\--- + \\~~~ + \\bar + \\~~~ + \\# baz + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\bar
+ \\
+ \\def foo(x)
+ \\ return 3
+ \\end
+ \\
+ , output);
+}
+
+test "Example 143" {
+ const output = try convert(std.testing.allocator,
+ \\~~~~ ruby startline=3 $%@#$
+ \\def foo(x)
+ \\ return 3
+ \\end
+ \\~~~~~~~
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\def foo(x)
+ \\ return 3
+ \\end
+ \\
+ , output);
+}
+
+test "Example 144" {
+ const output = try convert(std.testing.allocator,
+ \\````;
+ \\````
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\
+ , output);
+}
+
+test "Example 145" {
+ const output = try convert(std.testing.allocator,
+ \\``` aa ```
+ \\foo
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\aa
+ \\foo
foo
+ \\
+ , output);
+}
+
+test "Example 147" {
+ const output = try convert(std.testing.allocator,
+ \\```
+ \\``` aaa
+ \\```
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\``` aaa
+ \\
+ , output);
+}
+
+test "Example 148" {
+ const output = try convert(std.testing.allocator,
+ \\
+ \\+ \\**Hello**, + \\ + \\_world_. + \\+ \\ |
+ \\+ \\**Hello**, + \\+ \\ |
+ \\ hi + \\ | + \\
+ \\ hi + \\ | + \\
okay.
+ , output); +} + +test "Example 150" { + const output = try convert(std.testing.allocator, + \\ + \\*foo* + , output); +} + +test "Example 152" { + const output = try convert(std.testing.allocator, + \\Markdown
+ \\bar
+ , output); +} + +test "Example 156" { + const output = try convert(std.testing.allocator, + \\ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 160" { + const output = try convert(std.testing.allocator, + \\+ \\foo + \\ |
+ \\foo + \\ |
foo
+ \\foo
+ \\import Text.HTML.TagSoup
+ \\
+ \\main :: IO ()
+ \\main = print $ parseTags tags
+ \\
+ \\okay
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\
+ \\import Text.HTML.TagSoup
+ \\
+ \\main :: IO ()
+ \\main = print $ parseTags tags
+ \\
+ \\okay
+ , output); +} + +test "Example 170" { + const output = try convert(std.testing.allocator, + \\ + \\okay + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + \\okay
+ , output); +} + +test "Example 171" { + const output = try convert(std.testing.allocator, + \\ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 172" { + const output = try convert(std.testing.allocator, + \\ + \\okay + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + \\okay
+ , output); +} + +test "Example 173" { + const output = try convert(std.testing.allocator, + \\ + \\*foo* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + \\foo
+ , output); +} + +test "Example 177" { + const output = try convert(std.testing.allocator, + \\*bar* + \\*baz* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\*bar* + \\baz
+ , output); +} + +test "Example 178" { + const output = try convert(std.testing.allocator, + \\1. *bar* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\1. *bar* + , output); +} + +test "Example 179" { + const output = try convert(std.testing.allocator, + \\ + \\okay + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + \\okay
+ , output); +} + +test "Example 180" { + const output = try convert(std.testing.allocator, + \\'; + \\ + \\?> + \\okay + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\'; + \\ + \\?> + \\okay
+ , output); +} + +test "Example 181" { + const output = try convert(std.testing.allocator, + \\ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 182" { + const output = try convert(std.testing.allocator, + \\ + \\okay + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + \\okay
+ , output); +} + +test "Example 183" { + const output = try convert(std.testing.allocator, + \\ + \\ + \\ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + \\<!-- foo -->
+ \\
+ , output);
+}
+
+test "Example 184" {
+ const output = try convert(std.testing.allocator,
+ \\ <div>
+ \\
+ , output);
+}
+
+test "Example 185" {
+ const output = try convert(std.testing.allocator,
+ \\Foo
+ \\Foo
+ \\Foo + \\ + \\baz
+ , output); +} + +test "Example 188" { + const output = try convert(std.testing.allocator, + \\Emphasized text.
+ \\+ \\Hi + \\ | + \\ + \\
+ \\Hi + \\ | + \\
+ \\ Hi + \\ | + \\ + \\
[foo]: /url 'title
+ \\with blank line'
+ \\[foo]
+ , output); +} + +test "Example 198" { + const output = try convert(std.testing.allocator, + \\[foo]: + \\/url + \\ + \\[foo] + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 199" { + const output = try convert(std.testing.allocator, + \\[foo]: + \\ + \\[foo] + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[foo]:
+ \\[foo]
+ , output); +} + +test "Example 200" { + const output = try convert(std.testing.allocator, + \\[foo]: <> + \\ + \\[foo] + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 201" { + const output = try convert(std.testing.allocator, + \\[foo]:[foo]:
[foo]
+ , output); +} + +test "Example 202" { + const output = try convert(std.testing.allocator, + \\[foo]: /url\bar\*baz "foo\"bar\baz" + \\ + \\[foo] + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 203" { + const output = try convert(std.testing.allocator, + \\[foo] + \\ + \\[foo]: url + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 204" { + const output = try convert(std.testing.allocator, + \\[foo] + \\ + \\[foo]: first + \\[foo]: second + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 205" { + const output = try convert(std.testing.allocator, + \\[FOO]: /url + \\ + \\[Foo] + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 206" { + const output = try convert(std.testing.allocator, + \\[ΑΓΩ]: /φου + \\ + \\[αγω] + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 207" { + const output = try convert(std.testing.allocator, + \\[foo]: /url + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings("", output); +} + +test "Example 208" { + const output = try convert(std.testing.allocator, + \\[ + \\foo + \\]: /url + \\bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\bar
+ , output); +} + +test "Example 209" { + const output = try convert(std.testing.allocator, + \\[foo]: /url "title" ok + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[foo]: /url "title" ok
+ , output); +} + +test "Example 210" { + const output = try convert(std.testing.allocator, + \\[foo]: /url + \\"title" ok + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\"title" ok
+ , output); +} + +test "Example 211" { + const output = try convert(std.testing.allocator, + \\ [foo]: /url "title" + \\ + \\[foo] + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[foo]: /url "title"
+ \\
+ \\[foo]
+ , output); +} + +test "Example 212" { + const output = try convert(std.testing.allocator, + \\``` + \\[foo]: /url + \\``` + \\ + \\[foo] + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[foo]: /url
+ \\
+ \\[foo]
+ , output); +} + +test "Example 213" { + const output = try convert(std.testing.allocator, + \\Foo + \\[bar]: /baz + \\ + \\[bar] + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\Foo + \\[bar]: /baz
+ \\[bar]
+ , output); +} + +test "Example 214" { + const output = try convert(std.testing.allocator, + \\# [Foo] + \\[foo]: /url + \\> bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\+ \\+ , output); +} + +test "Example 215" { + const output = try convert(std.testing.allocator, + \\[foo]: /url + \\bar + \\=== + \\[foo] + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\bar
+ \\
=== + \\foo
+ , output); +} + +test "Example 217" { + const output = try convert(std.testing.allocator, + \\[foo]: /foo-url "foo" + \\[bar]: /bar-url + \\ "bar" + \\[baz]: /baz-url + \\ + \\[foo], + \\[bar], + \\[baz] + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 218" { + const output = try convert(std.testing.allocator, + \\[foo] + \\ + \\> [foo]: /url + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + \\+ \\+ , output); +} + +test "Example 219" { + const output = try convert(std.testing.allocator, + \\aaa + \\ + \\bbb + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\
aaa
+ \\bbb
+ , output); +} + +test "Example 220" { + const output = try convert(std.testing.allocator, + \\aaa + \\bbb + \\ + \\ccc + \\ddd + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\aaa + \\bbb
+ \\ccc + \\ddd
+ , output); +} + +test "Example 221" { + const output = try convert(std.testing.allocator, + \\aaa + \\ + \\ + \\bbb + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\aaa
+ \\bbb
+ , output); +} + +test "Example 222" { + const output = try convert(std.testing.allocator, + \\ aaa + \\ bbb + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\aaa + \\bbb
+ , output); +} + +test "Example 223" { + const output = try convert(std.testing.allocator, + \\aaa + \\ bbb + \\ ccc + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\aaa + \\bbb + \\ccc
+ , output); +} + +test "Example 224" { + const output = try convert(std.testing.allocator, + \\ aaa + \\bbb + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\aaa + \\bbb
+ , output); +} + +test "Example 225" { + const output = try convert(std.testing.allocator, + \\ aaa + \\bbb + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\aaa
+ \\
+ \\bbb
+ , output); +} + +test "Example 226" { + const output = try convert(std.testing.allocator, + \\aaa + \\bbb + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\aaa
+ \\bbb
aaa
+ \\+ \\+ , output); +} + +test "Example 229" { + const output = try convert(std.testing.allocator, + \\># Foo + \\>bar + \\> baz + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\Foo
+ \\bar + \\baz
+ \\
+ \\+ , output); +} + +test "Example 230" { + const output = try convert(std.testing.allocator, + \\ > # Foo + \\ > bar + \\ > baz + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\Foo
+ \\bar + \\baz
+ \\
+ \\+ , output); +} + +test "Example 231" { + const output = try convert(std.testing.allocator, + \\ > # Foo + \\ > bar + \\ > baz + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\Foo
+ \\bar + \\baz
+ \\
> # Foo
+ \\> bar
+ \\> baz
+ \\
+ , output);
+}
+
+test "Example 232" {
+ const output = try convert(std.testing.allocator,
+ \\> # Foo
+ \\> bar
+ \\baz
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\+ \\+ , output); +} + +test "Example 233" { + const output = try convert(std.testing.allocator, + \\> bar + \\baz + \\> foo + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\Foo
+ \\bar + \\baz
+ \\
+ \\+ , output); +} + +test "Example 234" { + const output = try convert(std.testing.allocator, + \\> foo + \\--- + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\bar + \\baz + \\foo
+ \\
+ \\+ \\foo
+ \\
+ \\+ \\+ \\
+ \\- foo
+ \\
+ \\+ \\+ \\foo + \\
bar
+ \\
+ , output);
+}
+
+test "Example 237" {
+ const output = try convert(std.testing.allocator,
+ \\> ```
+ \\foo
+ \\```
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\+ \\+ \\+ \\
foo
+ \\
+ , output);
+}
+
+test "Example 238" {
+ const output = try convert(std.testing.allocator,
+ \\> foo
+ \\ - bar
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\+ \\+ , output); +} + +test "Example 239" { + const output = try convert(std.testing.allocator, + \\> + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo + \\- bar
+ \\
+ \\+ , output); +} + +test "Example 240" { + const output = try convert(std.testing.allocator, + \\> + \\> + \\> + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\
+ \\+ , output); +} + +test "Example 241" { + const output = try convert(std.testing.allocator, + \\> + \\> foo + \\> + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\
+ \\+ , output); +} + +test "Example 242" { + const output = try convert(std.testing.allocator, + \\> foo + \\ + \\> bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ \\
+ \\+ \\foo
+ \\
+ \\+ , output); +} + +test "Example 243" { + const output = try convert(std.testing.allocator, + \\> foo + \\> bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\bar
+ \\
+ \\+ , output); +} + +test "Example 244" { + const output = try convert(std.testing.allocator, + \\> foo + \\> + \\> bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo + \\bar
+ \\
+ \\+ , output); +} + +test "Example 245" { + const output = try convert(std.testing.allocator, + \\foo + \\> bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ \\bar
+ \\
foo
+ \\+ \\+ , output); +} + +test "Example 246" { + const output = try convert(std.testing.allocator, + \\> aaa + \\*** + \\> bbb + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\bar
+ \\
+ \\+ \\aaa
+ \\
+ \\+ , output); +} + +test "Example 247" { + const output = try convert(std.testing.allocator, + \\> bar + \\baz + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\bbb
+ \\
+ \\+ , output); +} + +test "Example 248" { + const output = try convert(std.testing.allocator, + \\> bar + \\ + \\baz + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\bar + \\baz
+ \\
+ \\+ \\bar
+ \\
baz
+ , output); +} + +test "Example 249" { + const output = try convert(std.testing.allocator, + \\> bar + \\> + \\baz + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\+ \\+ \\bar
+ \\
baz
+ , output); +} + +test "Example 250" { + const output = try convert(std.testing.allocator, + \\> > > foo + \\bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\+ \\+ , output); +} + +test "Example 251" { + const output = try convert(std.testing.allocator, + \\>>> foo + \\> bar + \\>>baz + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\+ \\+ \\+ \\+ \\foo + \\bar
+ \\
+ \\+ , output); +} + +test "Example 252" { + const output = try convert(std.testing.allocator, + \\> code + \\ + \\> not code + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\+ \\+ \\+ \\+ \\foo + \\bar + \\baz
+ \\
+ \\+ \\+ \\code + \\
+ \\+ , output); +} + +test "Example 253" { + const output = try convert(std.testing.allocator, + \\A paragraph + \\with two lines. + \\ + \\ indented code + \\ + \\> A block quote. + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\not code
+ \\
A paragraph + \\with two lines.
+ \\indented code
+ \\
+ \\+ \\+ , output); +} + +test "Example 254" { + const output = try convert(std.testing.allocator, + \\1. A paragraph + \\ with two lines. + \\ + \\ indented code + \\ + \\ > A block quote. + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\A block quote.
+ \\
A paragraph + \\with two lines.
+ \\indented code
+ \\
+ \\+ \\+ \\A block quote.
+ \\
two
+ , output); +} + +test "Example 256" { + const output = try convert(std.testing.allocator, + \\- one + \\ + \\ two + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\one
+ \\two
+ \\ two
+ \\
+ , output);
+}
+
+test "Example 258" {
+ const output = try convert(std.testing.allocator,
+ \\ - one
+ \\
+ \\ two
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\one
+ \\two
+ \\+ \\+ , output); +} + +test "Example 260" { + const output = try convert(std.testing.allocator, + \\>>- one + \\>> + \\ > > two + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\+ \\+ \\+ \\
+ \\- + \\
+ \\one
+ \\two
+ \\
+ \\+ , output); +} + +test "Example 261" { + const output = try convert(std.testing.allocator, + \\-one + \\ + \\2.two + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\+ \\+ \\+ \\
+ \\- one
+ \\two
+ \\
-one
+ \\2.two
+ , output); +} + +test "Example 262" { + const output = try convert(std.testing.allocator, + \\- foo + \\ + \\ + \\ bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ \\bar
+ \\foo
+ \\bar
+ \\
+ \\baz
+ \\+ \\+ \\bam
+ \\
Foo
+ \\bar
+ \\
+ \\
+ \\baz
+ \\
+ \\1234567890. not ok
+ , output); +} + +test "Example 267" { + const output = try convert(std.testing.allocator, + \\0. ok + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\-1. not ok
+ , output); +} + +test "Example 270" { + const output = try convert(std.testing.allocator, + \\- foo + \\ + \\ bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ \\bar
+ \\
+ \\foo
+ \\bar
+ \\
+ \\indented code
+ \\
+ \\paragraph
+ \\more code
+ \\
+ , output);
+}
+
+test "Example 273" {
+ const output = try convert(std.testing.allocator,
+ \\1. indented code
+ \\
+ \\ paragraph
+ \\
+ \\ more code
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\indented code
+ \\
+ \\paragraph
+ \\more code
+ \\
+ \\ indented code
+ \\
+ \\paragraph
+ \\more code
+ \\
+ \\foo
+ \\bar
+ , output); +} + +test "Example 276" { + const output = try convert(std.testing.allocator, + \\- foo + \\ + \\ bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\bar
+ , output); +} + +test "Example 277" { + const output = try convert(std.testing.allocator, + \\- foo + \\ + \\ bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ \\bar
+ \\bar
+ \\
+ \\baz
+ \\
+ \\foo
+ , output); +} + +test "Example 281" { + const output = try convert(std.testing.allocator, + \\- foo + \\- + \\- bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo + \\*
+ \\foo + \\1.
+ , output); +} + +test "Example 286" { + const output = try convert(std.testing.allocator, + \\ 1. A paragraph + \\ with two lines. + \\ + \\ indented code + \\ + \\ > A block quote. + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\A paragraph + \\with two lines.
+ \\indented code
+ \\
+ \\+ \\+ \\A block quote.
+ \\
A paragraph + \\with two lines.
+ \\indented code
+ \\
+ \\+ \\+ \\A block quote.
+ \\
A paragraph + \\with two lines.
+ \\indented code
+ \\
+ \\+ \\+ \\A block quote.
+ \\
1. A paragraph
+ \\ with two lines.
+ \\
+ \\ indented code
+ \\
+ \\ > A block quote.
+ \\
+ , output);
+}
+
+test "Example 290" {
+ const output = try convert(std.testing.allocator,
+ \\ 1. A paragraph
+ \\with two lines.
+ \\
+ \\ indented code
+ \\
+ \\ > A block quote.
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\A paragraph + \\with two lines.
+ \\indented code
+ \\
+ \\+ \\+ \\A block quote.
+ \\
+ \\+ , output); +} + +test "Example 293" { + const output = try convert(std.testing.allocator, + \\> 1. > Blockquote + \\> continued here. + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\+ \\
+ \\- + \\
+ \\+ \\+ \\Blockquote + \\continued here.
+ \\
+ \\+ , output); +} + +test "Example 294" { + const output = try convert(std.testing.allocator, + \\- foo + \\ - bar + \\ - baz + \\ - boo + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\+ \\
+ \\- + \\
+ \\+ \\+ \\Blockquote + \\continued here.
+ \\
Foo
+ \\The number of windows in my house is + \\14. The number of doors is 6.
+ , output); +} + +test "Example 305" { + const output = try convert(std.testing.allocator, + \\The number of windows in my house is + \\1. The number of doors is 6. + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\The number of windows in my house is
+ \\foo
+ \\bar
+ \\baz
+ \\baz
+ \\bim
+ \\foo
+ \\notcode
+ \\foo
+ \\code
+ \\
+ , output);
+}
+
+test "Example 310" {
+ const output = try convert(std.testing.allocator,
+ \\- a
+ \\ - b
+ \\ - c
+ \\ - d
+ \\ - e
+ \\ - f
+ \\- g
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\a
+ \\b
+ \\c
+ \\a
+ \\b
+ \\3. c
+ \\
+ , output);
+}
+
+test "Example 314" {
+ const output = try convert(std.testing.allocator,
+ \\- a
+ \\- b
+ \\
+ \\- c
+ );
+ defer std.testing.allocator.free(output);
+
+ try std.testing.expectEqualStrings(
+ \\a
+ \\b
+ \\c
+ \\a
+ \\c
+ \\a
+ \\b
+ \\c
+ \\d
+ \\a
+ \\b
+ \\d
+ \\b
+ \\
+ \\
+ \\
+ \\b
+ \\c
+ \\+ \\+ \\b
+ \\
+ \\+ \\b
+ \\
c
+ \\
+ \\foo
+ \\
+ \\bar
+ \\foo
+ \\baz
+ \\a
+ \\d
+ \\hi
lo`
foo
foo ` bar
``
``
a
b
+ \\
foo bar baz
foo
foo bar baz
foo\
bar`
foo`bar
foo `` bar
*foo*
[not a link](/foo
)
<a href="
">`
<https://foo.bar.
baz>`
```foo``
+ , output); +} + +test "Example 348" { + const output = try convert(std.testing.allocator, + \\`foo + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\`foo
+ , output); +} + +test "Example 349" { + const output = try convert(std.testing.allocator, + \\`foo``bar`` + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\`foobar
foo bar
+ , output); +} + +test "Example 351" { + const output = try convert(std.testing.allocator, + \\a * foo bar* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\a * foo bar*
+ , output); +} + +test "Example 352" { + const output = try convert(std.testing.allocator, + \\a*"foo"* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\a*"foo"*
+ , output); +} + +test "Example 353" { + const output = try convert(std.testing.allocator, + \\* a * + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\* a *
+ , output); +} + +test "Example 354" { + const output = try convert(std.testing.allocator, + \\*$*alpha. + \\ + \\*£*bravo. + \\ + \\*€*charlie. + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\*$*alpha.
+ \\*£*bravo.
+ \\*€*charlie.
+ , output); +} + +test "Example 355" { + const output = try convert(std.testing.allocator, + \\foo*bar* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foobar
+ , output); +} + +test "Example 356" { + const output = try convert(std.testing.allocator, + \\5*6*78 + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\5678
+ , output); +} + +test "Example 357" { + const output = try convert(std.testing.allocator, + \\_foo bar_ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar
+ , output); +} + +test "Example 358" { + const output = try convert(std.testing.allocator, + \\_ foo bar_ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\_ foo bar_
+ , output); +} + +test "Example 359" { + const output = try convert(std.testing.allocator, + \\a_"foo"_ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\a_"foo"_
+ , output); +} + +test "Example 360" { + const output = try convert(std.testing.allocator, + \\foo_bar_ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo_bar_
+ , output); +} + +test "Example 361" { + const output = try convert(std.testing.allocator, + \\5_6_78 + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\5_6_78
+ , output); +} + +test "Example 362" { + const output = try convert(std.testing.allocator, + \\пристаням_стремятся_ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\пристаням_стремятся_
+ , output); +} + +test "Example 363" { + const output = try convert(std.testing.allocator, + \\aa_"bb"_cc + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\aa_"bb"_cc
+ , output); +} + +test "Example 364" { + const output = try convert(std.testing.allocator, + \\foo-_(bar)_ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo-(bar)
+ , output); +} + +test "Example 365" { + const output = try convert(std.testing.allocator, + \\_foo* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\_foo*
+ , output); +} + +test "Example 366" { + const output = try convert(std.testing.allocator, + \\*foo bar * + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\*foo bar *
+ , output); +} + +test "Example 367" { + const output = try convert(std.testing.allocator, + \\*foo bar + \\* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\*foo bar + \\*
+ , output); +} + +test "Example 368" { + const output = try convert(std.testing.allocator, + \\*(*foo) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\*(*foo)
+ , output); +} + +test "Example 369" { + const output = try convert(std.testing.allocator, + \\*(*foo*)* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\(foo)
+ , output); +} + +test "Example 370" { + const output = try convert(std.testing.allocator, + \\*foo*bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foobar
+ , output); +} + +test "Example 371" { + const output = try convert(std.testing.allocator, + \\_foo bar _ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\_foo bar _
+ , output); +} + +test "Example 372" { + const output = try convert(std.testing.allocator, + \\_(_foo) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\_(_foo)
+ , output); +} + +test "Example 373" { + const output = try convert(std.testing.allocator, + \\_(_foo_)_ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\(foo)
+ , output); +} + +test "Example 374" { + const output = try convert(std.testing.allocator, + \\_foo_bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\_foo_bar
+ , output); +} + +test "Example 375" { + const output = try convert(std.testing.allocator, + \\_пристаням_стремятся + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\_пристаням_стремятся
+ , output); +} + +test "Example 376" { + const output = try convert(std.testing.allocator, + \\_foo_bar_baz_ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo_bar_baz
+ , output); +} + +test "Example 377" { + const output = try convert(std.testing.allocator, + \\_(bar)_. + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\(bar).
+ , output); +} + +test "Example 378" { + const output = try convert(std.testing.allocator, + \\**foo bar** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar
+ , output); +} + +test "Example 379" { + const output = try convert(std.testing.allocator, + \\** foo bar** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\** foo bar**
+ , output); +} + +test "Example 380" { + const output = try convert(std.testing.allocator, + \\a**"foo"** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\a**"foo"**
+ , output); +} + +test "Example 381" { + const output = try convert(std.testing.allocator, + \\foo**bar** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foobar
+ , output); +} + +test "Example 382" { + const output = try convert(std.testing.allocator, + \\__foo bar__ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar
+ , output); +} + +test "Example 383" { + const output = try convert(std.testing.allocator, + \\__ foo bar__ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\__ foo bar__
+ , output); +} + +test "Example 384" { + const output = try convert(std.testing.allocator, + \\__ + \\foo bar__ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\__ + \\foo bar__
+ , output); +} + +test "Example 385" { + const output = try convert(std.testing.allocator, + \\a__"foo"__ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\a__"foo"__
+ , output); +} + +test "Example 386" { + const output = try convert(std.testing.allocator, + \\foo__bar__ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo__bar__
+ , output); +} + +test "Example 387" { + const output = try convert(std.testing.allocator, + \\5__6__78 + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\5__6__78
+ , output); +} + +test "Example 388" { + const output = try convert(std.testing.allocator, + \\пристаням__стремятся__ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\пристаням__стремятся__
+ , output); +} + +test "Example 389" { + const output = try convert(std.testing.allocator, + \\__foo, __bar__, baz__ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo, bar, baz
+ , output); +} + +test "Example 390" { + const output = try convert(std.testing.allocator, + \\foo-__(bar)__ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo-(bar)
+ , output); +} + +test "Example 391" { + const output = try convert(std.testing.allocator, + \\**foo bar ** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\**foo bar **
+ , output); +} + +test "Example 392" { + const output = try convert(std.testing.allocator, + \\**(**foo) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\**(**foo)
+ , output); +} + +test "Example 393" { + const output = try convert(std.testing.allocator, + \\*(**foo**)* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\(foo)
+ , output); +} + +test "Example 394" { + const output = try convert(std.testing.allocator, + \\**Gomphocarpus (*Gomphocarpus physocarpus*, syn. + \\*Asclepias physocarpa*)** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\Gomphocarpus (Gomphocarpus physocarpus, syn. + \\Asclepias physocarpa)
+ , output); +} + +test "Example 395" { + const output = try convert(std.testing.allocator, + \\**foo "*bar*" foo** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo "bar" foo
+ , output); +} + +test "Example 396" { + const output = try convert(std.testing.allocator, + \\**foo**bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foobar
+ , output); +} + +test "Example 397" { + const output = try convert(std.testing.allocator, + \\__foo bar __ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\__foo bar __
+ , output); +} + +test "Example 398" { + const output = try convert(std.testing.allocator, + \\__(__foo) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\__(__foo)
+ , output); +} + +test "Example 399" { + const output = try convert(std.testing.allocator, + \\_(__foo__)_ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\(foo)
+ , output); +} + +test "Example 400" { + const output = try convert(std.testing.allocator, + \\__foo__bar + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\__foo__bar
+ , output); +} + +test "Example 401" { + const output = try convert(std.testing.allocator, + \\__пристаням__стремятся + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\__пристаням__стремятся
+ , output); +} + +test "Example 402" { + const output = try convert(std.testing.allocator, + \\__foo__bar__baz__ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo__bar__baz
+ , output); +} + +test "Example 403" { + const output = try convert(std.testing.allocator, + \\__(bar)__. + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\(bar).
+ , output); +} + +test "Example 404" { + const output = try convert(std.testing.allocator, + \\*foo [bar](/url)* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar
+ , output); +} + +test "Example 405" { + const output = try convert(std.testing.allocator, + \\*foo + \\bar* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo + \\bar
+ , output); +} + +test "Example 406" { + const output = try convert(std.testing.allocator, + \\_foo __bar__ baz_ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar baz
+ , output); +} + +test "Example 407" { + const output = try convert(std.testing.allocator, + \\_foo _bar_ baz_ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar baz
+ , output); +} + +test "Example 408" { + const output = try convert(std.testing.allocator, + \\__foo_ bar_ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar
+ , output); +} + +test "Example 409" { + const output = try convert(std.testing.allocator, + \\*foo *bar** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar
+ , output); +} + +test "Example 410" { + const output = try convert(std.testing.allocator, + \\*foo **bar** baz* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar baz
+ , output); +} + +test "Example 411" { + const output = try convert(std.testing.allocator, + \\*foo**bar**baz* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foobarbaz
+ , output); +} + +test "Example 412" { + const output = try convert(std.testing.allocator, + \\*foo**bar* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo**bar
+ , output); +} + +test "Example 413" { + const output = try convert(std.testing.allocator, + \\***foo** bar* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar
+ , output); +} + +test "Example 414" { + const output = try convert(std.testing.allocator, + \\*foo **bar*** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar
+ , output); +} + +test "Example 415" { + const output = try convert(std.testing.allocator, + \\*foo**bar*** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foobar
+ , output); +} + +test "Example 416" { + const output = try convert(std.testing.allocator, + \\foo***bar***baz + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foobarbaz
+ , output); +} + +test "Example 417" { + const output = try convert(std.testing.allocator, + \\foo******bar*********baz + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foobar***baz
+ , output); +} + +test "Example 418" { + const output = try convert(std.testing.allocator, + \\*foo **bar *baz* bim** bop* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar baz bim bop
+ , output); +} + +test "Example 419" { + const output = try convert(std.testing.allocator, + \\*foo [*bar*](/url)* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar
+ , output); +} + +test "Example 420" { + const output = try convert(std.testing.allocator, + \\** is not an empty emphasis + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\** is not an empty emphasis
+ , output); +} + +test "Example 421" { + const output = try convert(std.testing.allocator, + \\**** is not an empty strong emphasis + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\**** is not an empty strong emphasis
+ , output); +} + +test "Example 422" { + const output = try convert(std.testing.allocator, + \\**foo [bar](/url)** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar
+ , output); +} + +test "Example 423" { + const output = try convert(std.testing.allocator, + \\**foo + \\bar** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo + \\bar
+ , output); +} + +test "Example 424" { + const output = try convert(std.testing.allocator, + \\__foo _bar_ baz__ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar baz
+ , output); +} + +test "Example 425" { + const output = try convert(std.testing.allocator, + \\__foo __bar__ baz__ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar baz
+ , output); +} + +test "Example 426" { + const output = try convert(std.testing.allocator, + \\____foo__ bar__ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar
+ , output); +} + +test "Example 427" { + const output = try convert(std.testing.allocator, + \\**foo **bar**** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar
+ , output); +} + +test "Example 428" { + const output = try convert(std.testing.allocator, + \\**foo *bar* baz** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar baz
+ , output); +} + +test "Example 429" { + const output = try convert(std.testing.allocator, + \\**foo*bar*baz** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foobarbaz
+ , output); +} + +test "Example 430" { + const output = try convert(std.testing.allocator, + \\***foo* bar** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar
+ , output); +} + +test "Example 431" { + const output = try convert(std.testing.allocator, + \\**foo *bar*** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar
+ , output); +} + +test "Example 432" { + const output = try convert(std.testing.allocator, + \\**foo *bar **baz** + \\bim* bop** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar baz + \\bim bop
+ , output); +} + +test "Example 433" { + const output = try convert(std.testing.allocator, + \\**foo [*bar*](/url)** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar
+ , output); +} + +test "Example 434" { + const output = try convert(std.testing.allocator, + \\__ is not an empty emphasis + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\__ is not an empty emphasis
+ , output); +} + +test "Example 435" { + const output = try convert(std.testing.allocator, + \\____ is not an empty strong emphasis + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\____ is not an empty strong emphasis
+ , output); +} + +test "Example 436" { + const output = try convert(std.testing.allocator, + \\foo *** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo ***
+ , output); +} + +test "Example 437" { + const output = try convert(std.testing.allocator, + \\foo *\** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo *
+ , output); +} + +test "Example 438" { + const output = try convert(std.testing.allocator, + \\foo *_* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo _
+ , output); +} + +test "Example 439" { + const output = try convert(std.testing.allocator, + \\foo ***** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo *****
+ , output); +} + +test "Example 440" { + const output = try convert(std.testing.allocator, + \\foo **\*** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo *
+ , output); +} + +test "Example 441" { + const output = try convert(std.testing.allocator, + \\foo **_** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo _
+ , output); +} + +test "Example 442" { + const output = try convert(std.testing.allocator, + \\**foo* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\*foo
+ , output); +} + +test "Example 443" { + const output = try convert(std.testing.allocator, + \\*foo** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo*
+ , output); +} + +test "Example 444" { + const output = try convert(std.testing.allocator, + \\***foo** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\*foo
+ , output); +} + +test "Example 445" { + const output = try convert(std.testing.allocator, + \\****foo* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\***foo
+ , output); +} + +test "Example 446" { + const output = try convert(std.testing.allocator, + \\**foo*** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo*
+ , output); +} + +test "Example 447" { + const output = try convert(std.testing.allocator, + \\*foo**** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo***
+ , output); +} + +test "Example 448" { + const output = try convert(std.testing.allocator, + \\foo ___ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo ___
+ , output); +} + +test "Example 449" { + const output = try convert(std.testing.allocator, + \\foo _\__ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo _
+ , output); +} + +test "Example 450" { + const output = try convert(std.testing.allocator, + \\foo _*_ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo *
+ , output); +} + +test "Example 451" { + const output = try convert(std.testing.allocator, + \\foo _____ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo _____
+ , output); +} + +test "Example 452" { + const output = try convert(std.testing.allocator, + \\foo __\___ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo _
+ , output); +} + +test "Example 453" { + const output = try convert(std.testing.allocator, + \\foo __*__ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo *
+ , output); +} + +test "Example 454" { + const output = try convert(std.testing.allocator, + \\__foo_ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\_foo
+ , output); +} + +test "Example 455" { + const output = try convert(std.testing.allocator, + \\_foo__ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo_
+ , output); +} + +test "Example 456" { + const output = try convert(std.testing.allocator, + \\___foo__ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\_foo
+ , output); +} + +test "Example 457" { + const output = try convert(std.testing.allocator, + \\____foo_ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\___foo
+ , output); +} + +test "Example 458" { + const output = try convert(std.testing.allocator, + \\__foo___ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo_
+ , output); +} + +test "Example 459" { + const output = try convert(std.testing.allocator, + \\_foo____ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo___
+ , output); +} + +test "Example 460" { + const output = try convert(std.testing.allocator, + \\**foo** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ , output); +} + +test "Example 461" { + const output = try convert(std.testing.allocator, + \\*_foo_* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ , output); +} + +test "Example 462" { + const output = try convert(std.testing.allocator, + \\__foo__ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ , output); +} + +test "Example 463" { + const output = try convert(std.testing.allocator, + \\_*foo*_ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ , output); +} + +test "Example 464" { + const output = try convert(std.testing.allocator, + \\****foo**** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ , output); +} + +test "Example 465" { + const output = try convert(std.testing.allocator, + \\____foo____ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ , output); +} + +test "Example 466" { + const output = try convert(std.testing.allocator, + \\******foo****** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ , output); +} + +test "Example 467" { + const output = try convert(std.testing.allocator, + \\***foo*** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ , output); +} + +test "Example 468" { + const output = try convert(std.testing.allocator, + \\_____foo_____ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ , output); +} + +test "Example 469" { + const output = try convert(std.testing.allocator, + \\*foo _bar* baz_ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo _bar baz_
+ , output); +} + +test "Example 470" { + const output = try convert(std.testing.allocator, + \\*foo __bar *baz bim__ bam* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar *baz bim bam
+ , output); +} + +test "Example 471" { + const output = try convert(std.testing.allocator, + \\**foo **bar baz** + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\**foo bar baz
+ , output); +} + +test "Example 472" { + const output = try convert(std.testing.allocator, + \\*foo *bar baz* + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\*foo bar baz
+ , output); +} + +test "Example 473" { + const output = try convert(std.testing.allocator, + \\*[bar*](/url) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\*bar*
+ , output); +} + +test "Example 474" { + const output = try convert(std.testing.allocator, + \\_foo [bar_](/url) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\_foo bar_
+ , output); +} + +test "Example 475" { + const output = try convert(std.testing.allocator, + \\**
a *
a _
[link](/my uri)
+ , output); +} + +test "Example 489" { + const output = try convert(std.testing.allocator, + \\[link]([link](foo + \\bar)
+ , output); +} + +test "Example 491" { + const output = try convert(std.testing.allocator, + \\[link]([link](
[link](<foo>)
+ , output); +} + +test "Example 494" { + const output = try convert(std.testing.allocator, + \\[a]( + \\[a](c) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[a](<b)c + \\[a](<b)c> + \\[a](c)
+ , output); +} + +test "Example 495" { + const output = try convert(std.testing.allocator, + \\[link](\(foo\)) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 496" { + const output = try convert(std.testing.allocator, + \\[link](foo(and(bar))) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 497" { + const output = try convert(std.testing.allocator, + \\[link](foo(and(bar)) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[link](foo(and(bar))
+ , output); +} + +test "Example 498" { + const output = try convert(std.testing.allocator, + \\[link](foo\(and\(bar\)) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 499" { + const output = try convert(std.testing.allocator, + \\[link]([link](/url "title "and" title")
+ , output); +} + +test "Example 509" { + const output = try convert(std.testing.allocator, + \\[link](/url 'title "and" title') + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 510" { + const output = try convert(std.testing.allocator, + \\[link]( /uri + \\ "title" ) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 511" { + const output = try convert(std.testing.allocator, + \\[link] (/uri) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[link] (/uri)
+ , output); +} + +test "Example 512" { + const output = try convert(std.testing.allocator, + \\[link [foo [bar]]](/uri) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 513" { + const output = try convert(std.testing.allocator, + \\[link] bar](/uri) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[link] bar](/uri)
+ , output); +} + +test "Example 514" { + const output = try convert(std.testing.allocator, + \\[link [bar](/uri) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[link bar
+ , output); +} + +test "Example 515" { + const output = try convert(std.testing.allocator, + \\[link \[bar](/uri) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 516" { + const output = try convert(std.testing.allocator, + \\[link *foo **bar** `#`*](/uri) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 517" { + const output = try convert(std.testing.allocator, + \\[](/uri) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 518" { + const output = try convert(std.testing.allocator, + \\[foo [bar](/uri)](/uri) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[foo bar](/uri)
+ , output); +} + +test "Example 519" { + const output = try convert(std.testing.allocator, + \\[foo *[bar [baz](/uri)](/uri)*](/uri) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[foo [bar baz](/uri)](/uri)
+ , output); +} + +test "Example 520" { + const output = try convert(std.testing.allocator, + \\](uri2)](uri3) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\*foo*
+ , output); +} + +test "Example 522" { + const output = try convert(std.testing.allocator, + \\[foo *bar](baz*) + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 523" { + const output = try convert(std.testing.allocator, + \\*foo [bar* baz] + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo [bar baz]
+ , output); +} + +test "Example 524" { + const output = try convert(std.testing.allocator, + \\[foo[foo
[foo](/uri)
[foohttps://example.com/?search=](uri)
+ , output); +} + +test "Example 527" { + const output = try convert(std.testing.allocator, + \\[foo][bar] + \\ + \\[bar]: /url "title" + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 528" { + const output = try convert(std.testing.allocator, + \\[link [foo [bar]]][ref] + \\ + \\[ref]: /uri + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 529" { + const output = try convert(std.testing.allocator, + \\[link \[bar][ref] + \\ + \\[ref]: /uri + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 530" { + const output = try convert(std.testing.allocator, + \\[link *foo **bar** `#`*][ref] + \\ + \\[ref]: /uri + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 531" { + const output = try convert(std.testing.allocator, + \\[][ref] + \\ + \\[ref]: /uri + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 532" { + const output = try convert(std.testing.allocator, + \\[foo [bar](/uri)][ref] + \\ + \\[ref]: /uri + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 533" { + const output = try convert(std.testing.allocator, + \\[foo *bar [baz][ref]*][ref] + \\ + \\[ref]: /uri + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 534" { + const output = try convert(std.testing.allocator, + \\*[foo*][ref] + \\ + \\[ref]: /uri + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\*foo*
+ , output); +} + +test "Example 535" { + const output = try convert(std.testing.allocator, + \\[foo *bar][ref]* + \\ + \\[ref]: /uri + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 536" { + const output = try convert(std.testing.allocator, + \\[foo[foo
[foo][ref]
[foohttps://example.com/?search=][ref]
+ , output); +} + +test "Example 539" { + const output = try convert(std.testing.allocator, + \\[foo][BaR] + \\ + \\[bar]: /url "title" + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 540" { + const output = try convert(std.testing.allocator, + \\[ẞ] + \\ + \\[SS]: /url + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 541" { + const output = try convert(std.testing.allocator, + \\[Foo + \\ bar]: /url + \\ + \\[Baz][Foo bar] + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 542" { + const output = try convert(std.testing.allocator, + \\[foo] [bar] + \\ + \\[bar]: /url "title" + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[foo] bar
+ , output); +} + +test "Example 543" { + const output = try convert(std.testing.allocator, + \\[foo] + \\[bar] + \\ + \\[bar]: /url "title" + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[foo] + \\bar
+ , output); +} + +test "Example 544" { + const output = try convert(std.testing.allocator, + \\[foo]: /url1 + \\ + \\[foo]: /url2 + \\ + \\[bar][foo] + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 545" { + const output = try convert(std.testing.allocator, + \\[bar][foo\!] + \\ + \\[foo!]: /url + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[bar][foo!]
+ , output); +} + +test "Example 546" { + const output = try convert(std.testing.allocator, + \\[foo][ref[] + \\ + \\[ref[]: /uri + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[foo][ref[]
+ \\[ref[]: /uri
+ , output); +} + +test "Example 547" { + const output = try convert(std.testing.allocator, + \\[foo][ref[bar]] + \\ + \\[ref[bar]]: /uri + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[foo][ref[bar]]
+ \\[ref[bar]]: /uri
+ , output); +} + +test "Example 548" { + const output = try convert(std.testing.allocator, + \\[[[foo]]] + \\ + \\[[[foo]]]: /url + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[[[foo]]]
+ \\[[[foo]]]: /url
+ , output); +} + +test "Example 549" { + const output = try convert(std.testing.allocator, + \\[foo][ref\[] + \\ + \\[ref\[]: /uri + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 550" { + const output = try convert(std.testing.allocator, + \\[bar\\]: /uri + \\ + \\[bar\\] + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 551" { + const output = try convert(std.testing.allocator, + \\[] + \\ + \\[]: /uri + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[]
+ \\[]: /uri
+ , output); +} + +test "Example 552" { + const output = try convert(std.testing.allocator, + \\[ + \\ ] + \\ + \\[ + \\ ]: /uri + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[ + \\]
+ \\[ + \\]: /uri
+ , output); +} + +test "Example 553" { + const output = try convert(std.testing.allocator, + \\[foo][] + \\ + \\[foo]: /url "title" + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 554" { + const output = try convert(std.testing.allocator, + \\[*foo* bar][] + \\ + \\[*foo* bar]: /url "title" + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 555" { + const output = try convert(std.testing.allocator, + \\[Foo][] + \\ + \\[foo]: /url "title" + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 556" { + const output = try convert(std.testing.allocator, + \\[foo] + \\[] + \\ + \\[foo]: /url "title" + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo + \\[]
+ , output); +} + +test "Example 557" { + const output = try convert(std.testing.allocator, + \\[foo] + \\ + \\[foo]: /url "title" + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 558" { + const output = try convert(std.testing.allocator, + \\[*foo* bar] + \\ + \\[*foo* bar]: /url "title" + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 559" { + const output = try convert(std.testing.allocator, + \\[[*foo* bar]] + \\ + \\[*foo* bar]: /url "title" + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[foo bar]
+ , output); +} + +test "Example 560" { + const output = try convert(std.testing.allocator, + \\[[bar [foo] + \\ + \\[foo]: /url + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[[bar foo
+ , output); +} + +test "Example 561" { + const output = try convert(std.testing.allocator, + \\[Foo] + \\ + \\[foo]: /url "title" + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 562" { + const output = try convert(std.testing.allocator, + \\[foo] bar + \\ + \\[foo]: /url + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo bar
+ , output); +} + +test "Example 563" { + const output = try convert(std.testing.allocator, + \\\[foo] + \\ + \\[foo]: /url "title" + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[foo]
+ , output); +} + +test "Example 564" { + const output = try convert(std.testing.allocator, + \\[foo*]: /url + \\ + \\*[foo*] + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\*foo*
+ , output); +} + +test "Example 565" { + const output = try convert(std.testing.allocator, + \\[foo][bar] + \\ + \\[foo]: /url1 + \\[bar]: /url2 + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 566" { + const output = try convert(std.testing.allocator, + \\[foo][] + \\ + \\[foo]: /url1 + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 567" { + const output = try convert(std.testing.allocator, + \\[foo]() + \\ + \\[foo]: /url1 + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 568" { + const output = try convert(std.testing.allocator, + \\[foo](not a link) + \\ + \\[foo]: /url1 + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo(not a link)
+ , output); +} + +test "Example 569" { + const output = try convert(std.testing.allocator, + \\[foo][bar][baz] + \\ + \\[baz]: /url + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[foo]bar
+ , output); +} + +test "Example 570" { + const output = try convert(std.testing.allocator, + \\[foo][bar][baz] + \\ + \\[baz]: /url1 + \\[bar]: /url2 + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 571" { + const output = try convert(std.testing.allocator, + \\[foo][bar][baz] + \\ + \\[baz]: /url1 + \\[foo]: /url2 + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\[foo]bar
+ , output); +} + +test "Example 572" { + const output = try convert(std.testing.allocator, + \\ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\My
+ \\[]
![[foo]]
+ \\[[foo]]: /url "title"
+ , output); +} + +test "Example 591" { + const output = try convert(std.testing.allocator, + \\![Foo] + \\ + \\[foo]: /url "title" + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\![foo]
+ , output); +} + +test "Example 593" { + const output = try convert(std.testing.allocator, + \\\![foo] + \\ + \\[foo]: /url "title" + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\!foo
+ , output); +} + +test "Example 594" { + const output = try convert(std.testing.allocator, + \\https://foo.bar.baz/test?q=hello&id=22&boolean
+ , output); +} + +test "Example 596" { + const output = try convert(std.testing.allocator, + \\<https://foo.bar/baz bim>
+ , output); +} + +test "Example 603" { + const output = try convert(std.testing.allocator, + \\<foo+@bar.example.com>
+ , output); +} + +test "Example 607" { + const output = try convert(std.testing.allocator, + \\<> + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\<>
+ , output); +} + +test "Example 608" { + const output = try convert(std.testing.allocator, + \\< https://foo.bar > + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\< https://foo.bar >
+ , output); +} + +test "Example 609" { + const output = try convert(std.testing.allocator, + \\<m:abc>
+ , output); +} + +test "Example 610" { + const output = try convert(std.testing.allocator, + \\<foo.bar.baz>
+ , output); +} + +test "Example 611" { + const output = try convert(std.testing.allocator, + \\https://example.com + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\https://example.com
+ , output); +} + +test "Example 612" { + const output = try convert(std.testing.allocator, + \\foo@bar.example.com + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo@bar.example.com
+ , output); +} + +test "Example 613" { + const output = try convert(std.testing.allocator, + \\Foo
<33> <__>
+ , output); +} + +test "Example 619" { + const output = try convert(std.testing.allocator, + \\ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\<a h*#ref="hi">
+ , output); +} + +test "Example 620" { + const output = try convert(std.testing.allocator, + \\< + \\foo>< a>< + \\foo><bar/ > + \\<foo bar=baz + \\bim!bop />
+ , output); +} + +test "Example 622" { + const output = try convert(std.testing.allocator, + \\ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\<a href='bar'title=title>
+ , output); +} + +test "Example 623" { + const output = try convert(std.testing.allocator, + \\</a href="foo">
+ , output); +} + +test "Example 625" { + const output = try convert(std.testing.allocator, + \\foo + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ , output); +} + +test "Example 626" { + const output = try convert(std.testing.allocator, + \\foo foo --> + \\ + \\foo foo --> + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo foo -->
+ \\foo foo -->
+ , output); +} + +test "Example 627" { + const output = try convert(std.testing.allocator, + \\foo + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ , output); +} + +test "Example 628" { + const output = try convert(std.testing.allocator, + \\foo + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ , output); +} + +test "Example 629" { + const output = try convert(std.testing.allocator, + \\foo &<]]> + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo &<]]>
+ , output); +} + +test "Example 630" { + const output = try convert(std.testing.allocator, + \\foo + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 631" { + const output = try convert(std.testing.allocator, + \\foo + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\ + , output); +} + +test "Example 632" { + const output = try convert(std.testing.allocator, + \\ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\<a href=""">
+ , output); +} + +test "Example 633" { + const output = try convert(std.testing.allocator, + \\foo + \\baz + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ \\baz
foo
+ \\baz
foo
+ \\baz
foo
+ \\bar
foo
+ \\bar
foo
+ \\bar
foo
+ \\bar
code span
code\ span
foo\
+ , output); +} + +test "Example 645" { + const output = try convert(std.testing.allocator, + \\foo + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo
+ , output); +} + +test "Example 646" { + const output = try convert(std.testing.allocator, + \\### foo\ + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo + \\baz
+ , output); +} + +test "Example 649" { + const output = try convert(std.testing.allocator, + \\foo + \\ baz + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\foo + \\baz
+ , output); +} + +test "Example 650" { + const output = try convert(std.testing.allocator, + \\hello $.;'there + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\hello $.;'there
+ , output); +} + +test "Example 651" { + const output = try convert(std.testing.allocator, + \\Foo χρῆν + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\Foo χρῆν
+ , output); +} + +test "Example 652" { + const output = try convert(std.testing.allocator, + \\Multiple spaces + ); + defer std.testing.allocator.free(output); + + try std.testing.expectEqualStrings( + \\Multiple spaces
+ , output); +} diff --git a/ziglue/src/main.zig b/ziglue/src/main.zig new file mode 100644 index 0000000..b50c9b9 --- /dev/null +++ b/ziglue/src/main.zig @@ -0,0 +1,65 @@ +const std = @import("std"); + +pub fn find_blocks(src: []const u8, blocks: *std.ArrayList([]const u8)) !void { + var idx: usize = 0; + var blk: usize = 0; + + while (idx < src.len) { + const end = std.mem.indexOfAnyPos(u8, src, idx, "\n") orelse src.len; + const line = src[idx..end]; + if (std.mem.indexOfNone(u8, line, " \t\r\n") == null) { + // the line is blank; a block has ended. + const block = src[blk..end]; + + std.debug.print("BLOCK:\n{s}", .{block}); + + try blocks.append(block); + blk = end + 1; + } + idx = end + 1; + } +} + +pub fn convert(alloc: std.mem.Allocator, md: []const u8) ![]const u8 { + return try alloc.dupe(u8, md); + + // _ = alloc; + // _ = md; + // return error.UhOh; + // return error.NotImplemented; + + // return alloc.dupe(u8, "Hello World!"); +} + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + const alloc = gpa.allocator(); + + defer _ = gpa.deinit(); + + var args = try std.process.argsWithAllocator(alloc); + defer args.deinit(); + std.debug.assert(args.skip()); + + var blocks = std.ArrayList([]const u8).init(alloc); + defer blocks.deinit(); + + while (args.next()) |fname| { + const src = load: { + const file = try std.fs.cwd().openFile(fname, .{ .mode = .read_only }); + defer file.close(); + break :load try file.readToEndAlloc(alloc, std.math.maxInt(u32)); + }; + defer alloc.free(src); + + std.log.debug("arg '{s}' {d} bytes", .{ fname, src.len }); + + blocks.clearRetainingCapacity(); + try find_blocks(src, &blocks); + + // try parse(alloc, src); + + // const tokens = try parse(alloc, src); + // defer alloc.free(tokens); + } +}