mod(node2buffer): improve flow for list_items
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 29s
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 29s
This commit is contained in:
@@ -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 => {},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user