diff options
| -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 { |
