Skip to content

Commit 850c431

Browse files
committed
Add arrows in the <summary> element, making them properly titled.
1 parent da14a19 commit 850c431

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

lua/tui/html.lua

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ local Element = require('lean.tui').Element
33
local html = {}
44

55
vim.api.nvim_set_hl(0, 'tui.html.b', { bold = true })
6+
vim.api.nvim_set_hl(0, 'tui.html.summary', { link = 'Title' })
67
vim.api.nvim_set_hl(0, 'tui.html.unsupported', { link = 'ErrorMsg' })
78

89
html.Tag = vim.defaulttable(function(tag)
@@ -17,18 +18,16 @@ end)
1718

1819
---A `<details>` tag.
1920
function html.Tag.details(children)
20-
-- TODO: foldable, when it exists, and this should maybe go search for the
21-
-- summary child and assemble it here so we have a "real" title.
22-
return Element:titled {
23-
title = '',
24-
margin = 0,
25-
body = children,
26-
}
21+
return Element:new { children = children }
2722
end
2823

2924
---A `<summary>` tag (within `details`).
3025
function html.Tag.summary(children)
31-
return Element:new { children = children }
26+
return Element:new {
27+
text = '',
28+
hlgroup = 'tui.html.summary',
29+
children = children,
30+
}
3231
end
3332

3433
---Just render the children, as we don't (yet?) support passing through styles.

spec/tui/html_spec.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ describe('tui.html', function()
3939
end)
4040

4141
describe('<summary>', function()
42-
it('renders summary as passthrough', function()
42+
it('renders summary with marker', function()
4343
local el = Tag.summary { Element:new { text = 'sum' } }
44-
assert.is.equal('sum', el:to_string())
44+
assert.is.equal('sum', el:to_string())
4545
end)
4646
end)
4747

4848
describe('<details>', function()
4949
it('renders details as titled block', function()
5050
local el = Tag.details { Element:new { text = 'body' } }
51-
assert.is.equal('body', el:to_string())
51+
assert.is.equal('body', el:to_string())
5252
end)
5353
end)
5454

0 commit comments

Comments
 (0)