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.fg = .{ .index = 3 };
|
||||||
style.ul_style = .single;
|
style.ul_style = .single;
|
||||||
},
|
},
|
||||||
|
.list_item => {
|
||||||
|
style.fg = .{ .index = 1 };
|
||||||
|
},
|
||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine content that needs to be displayed
|
// determine content that needs to be displayed
|
||||||
const content = value: {
|
const content = value: {
|
||||||
switch (node.token.element.type) {
|
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],
|
.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],
|
.link => break :value input[node.token.start + 1 .. node.token.start + 1 + node.title.?.len],
|
||||||
.code_close => {
|
.code_close => {
|
||||||
@@ -212,14 +216,13 @@ pub fn toBuffer(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
.list_item => {
|
.list_item => {
|
||||||
// TODO: detect nested lists and adjust indentation accordingly
|
|
||||||
try array.append(.{
|
try array.append(.{
|
||||||
.char = .{ .grapheme = "\n" },
|
.char = .{ .grapheme = "\n" },
|
||||||
});
|
});
|
||||||
for (content, 0..) |_, i| {
|
for (content, 0..) |_, i| {
|
||||||
try array.append(.{
|
try array.append(.{
|
||||||
.char = .{ .grapheme = content[i .. i + 1] },
|
.char = .{ .grapheme = content[i .. i + 1] },
|
||||||
.style = .{ .fg = .{ .index = 1 } },
|
.style = style,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -252,6 +255,9 @@ pub fn toBuffer(
|
|||||||
.href_close => {
|
.href_close => {
|
||||||
style.fg = .default;
|
style.fg = .default;
|
||||||
},
|
},
|
||||||
|
.list_item => {
|
||||||
|
style.fg = .default;
|
||||||
|
},
|
||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user