mod(node2buffer): correct handling of code's and ``block``'s entries
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 33s
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 33s
This commit is contained in:
@@ -30,8 +30,7 @@ pub fn toBuffer(
|
|||||||
style.fg = .{ .index = 2 };
|
style.fg = .{ .index = 2 };
|
||||||
},
|
},
|
||||||
.block => {
|
.block => {
|
||||||
// TODO: what should I do with blocks?
|
style.dim = true;
|
||||||
style.fg = .{ .index = 7 };
|
|
||||||
next_start = node.token.start;
|
next_start = node.token.start;
|
||||||
},
|
},
|
||||||
.code => {
|
.code => {
|
||||||
@@ -55,7 +54,14 @@ pub fn toBuffer(
|
|||||||
.text => break :value input[node.token.start..node.token.end],
|
.text => 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],
|
||||||
// TODO: use corresponding link contents to create 'real' links using escape sequences
|
// TODO: use corresponding link contents to create 'real' links using escape sequences
|
||||||
.bold_close, .italic_close, .block_close, .code_close, .title_close, .href_close => {
|
.code_close => {
|
||||||
|
if (next_start) |s| {
|
||||||
|
next_start = null;
|
||||||
|
break :value input[s + 1 .. node.token.end - 1];
|
||||||
|
}
|
||||||
|
break :value "";
|
||||||
|
},
|
||||||
|
.bold_close, .italic_close, .block_close, .title_close, .href_close => {
|
||||||
if (next_start) |s| {
|
if (next_start) |s| {
|
||||||
next_start = null;
|
next_start = null;
|
||||||
break :value input[s..node.token.end];
|
break :value input[s..node.token.end];
|
||||||
@@ -139,7 +145,7 @@ pub fn toBuffer(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.block_close, .code_close => {
|
.block_close => {
|
||||||
// generate a `block` i.e.
|
// generate a `block` i.e.
|
||||||
// 01 | ...
|
// 01 | ...
|
||||||
// 02 | ...
|
// 02 | ...
|
||||||
@@ -163,30 +169,30 @@ pub fn toBuffer(
|
|||||||
for (1..rows + 1) |r| {
|
for (1..rows + 1) |r| {
|
||||||
try array.append(.{
|
try array.append(.{
|
||||||
.char = .{ .grapheme = " " },
|
.char = .{ .grapheme = " " },
|
||||||
.style = .{ .dim = true },
|
.style = .{ .fg = .{ .index = 0 } },
|
||||||
});
|
});
|
||||||
try array.append(.{
|
try array.append(.{
|
||||||
.char = .{ .grapheme = " " },
|
.char = .{ .grapheme = " " },
|
||||||
.style = .{ .dim = true },
|
.style = .{ .fg = .{ .index = 0 } },
|
||||||
});
|
});
|
||||||
for (1..pad + 1) |i| {
|
for (1..pad + 1) |i| {
|
||||||
const digit = vaxis.widgets.LineNumbers.extractDigit(r, pad - i);
|
const digit = vaxis.widgets.LineNumbers.extractDigit(r, pad - i);
|
||||||
try array.append(.{
|
try array.append(.{
|
||||||
.char = .{ .grapheme = digits[digit .. digit + 1] },
|
.char = .{ .grapheme = digits[digit .. digit + 1] },
|
||||||
.style = .{ .dim = true },
|
.style = .{ .fg = .{ .index = 0 } },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
try array.append(.{
|
try array.append(.{
|
||||||
.char = .{ .grapheme = " " },
|
.char = .{ .grapheme = " " },
|
||||||
.style = .{ .dim = true },
|
.style = .{ .fg = .{ .index = 0 } },
|
||||||
});
|
});
|
||||||
try array.append(.{
|
try array.append(.{
|
||||||
.char = .{ .grapheme = "│" },
|
.char = .{ .grapheme = "│" },
|
||||||
.style = .{ .dim = true },
|
.style = .{ .fg = .{ .index = 0 } },
|
||||||
});
|
});
|
||||||
try array.append(.{
|
try array.append(.{
|
||||||
.char = .{ .grapheme = " " },
|
.char = .{ .grapheme = " " },
|
||||||
.style = .{ .dim = true },
|
.style = .{ .fg = .{ .index = 0 } },
|
||||||
});
|
});
|
||||||
for (c..content.len) |c_i| {
|
for (c..content.len) |c_i| {
|
||||||
try array.append(.{
|
try array.append(.{
|
||||||
@@ -221,7 +227,6 @@ pub fn toBuffer(
|
|||||||
style.fg = .default;
|
style.fg = .default;
|
||||||
},
|
},
|
||||||
.block_close => {
|
.block_close => {
|
||||||
// TODO: what should I do with blocks?
|
|
||||||
style.fg = .default;
|
style.fg = .default;
|
||||||
},
|
},
|
||||||
.code_close => {
|
.code_close => {
|
||||||
|
|||||||
Reference in New Issue
Block a user