From aff062f144e2c9399f218f8e4ec0c07d0eac1845 Mon Sep 17 00:00:00 2001 From: Yves Biener Date: Sun, 27 Oct 2024 19:28:32 +0100 Subject: [PATCH] mod(node2buffer): improve flow for list_items --- src/widget/node2buffer.zig | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/widget/node2buffer.zig b/src/widget/node2buffer.zig index de5e348..fcee259 100644 --- a/src/widget/node2buffer.zig +++ b/src/widget/node2buffer.zig @@ -45,12 +45,16 @@ pub fn toBuffer( style.fg = .{ .index = 3 }; style.ul_style = .single; }, + .list_item => { + style.fg = .{ .index = 1 }; + }, else => {}, } // determine content that needs to be displayed const content = value: { switch (node.token.element.type) { + // NOTE: do not support ordered lists? (as it only accepts `1.` and not `2.`, etc.) .text, .list_item => break :value input[node.token.start..node.token.end], .link => break :value input[node.token.start + 1 .. node.token.start + 1 + node.title.?.len], .code_close => { @@ -212,14 +216,13 @@ pub fn toBuffer( } }, .list_item => { - // TODO: detect nested lists and adjust indentation accordingly try array.append(.{ .char = .{ .grapheme = "\n" }, }); for (content, 0..) |_, i| { try array.append(.{ .char = .{ .grapheme = content[i .. i + 1] }, - .style = .{ .fg = .{ .index = 1 } }, + .style = style, }); } }, @@ -252,6 +255,9 @@ pub fn toBuffer( .href_close => { style.fg = .default; }, + .list_item => { + style.fg = .default; + }, else => {}, }