diff options
| author | t <t@tjp.lol> | 2026-06-17 09:02:09 -0600 |
|---|---|---|
| committer | t <t@tjp.lol> | 2026-06-17 09:02:33 -0600 |
| commit | e1ed3d82446defe127f87c90364b51bbd78f1eda (patch) | |
| tree | 191ccde4c61daa7590423f6f978ed8b899630aff /src | |
| parent | 7847db3b13bc8639b5173ce3c56ae4068617ce12 (diff) | |
fix blank lines after listings
Diffstat (limited to 'src')
| -rw-r--r-- | src/markdown.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/markdown.zig b/src/markdown.zig index 58f1b97..13358b4 100644 --- a/src/markdown.zig +++ b/src/markdown.zig @@ -306,6 +306,7 @@ pub const Renderer = struct { }, c.MD_BLOCK_UL, c.MD_BLOCK_OL => { if (self.list_depth > 0) self.list_depth -= 1; + if (self.list_depth == 0 and self.list_item_depth == 0) self.appendBlank() catch |e| return self.fail(e); }, else => {}, } @@ -417,6 +418,21 @@ test "Renderer keeps soft breaks between inline-styled lines" { try testing.expect(std.mem.indexOf(u8, out.items[3], "strikethrough") != null); } +test "Renderer preserves blank line between list and following paragraph" { + var out: std.ArrayList([]const u8) = .empty; + defer { + for (out.items) |l| testing.allocator.free(l); + out.deinit(testing.allocator); + } + var r: Renderer = .{ .alloc = testing.allocator, .width = 80, .out_lines = &out }; + try r.render("- one\n- two\n\na summary here"); + try testing.expectEqual(@as(usize, 4), out.items.len); + try testing.expectEqualStrings("• one", out.items[0]); + try testing.expectEqualStrings("• two", out.items[1]); + try testing.expectEqualStrings("", out.items[2]); + try testing.expectEqualStrings("a summary here", out.items[3]); +} + test "Renderer preserves nested list indentation" { var out: std.ArrayList([]const u8) = .empty; defer { |
