commit 72892aab066a58524d670777512e9cab45e7310d
parent a0c64fe816f82010dea43d8bbe25475fbabfb562
Author: Justin M. Keyes <justinkz@gmail.com>
Date: Tue, 1 Oct 2024 12:51:16 +0200
docs(gen_help_html.lua): h4 pseudo-heading layout
Problem:
The <br> hack in a0c64fe816f8 causes weird layout if a "h4 pseudo-heading"
is not the only tag on the line. For example in the help text below, the
"*'buflisted'*" tag was treated as h4 and followed by <br>, which is
obviously wrong:
*'buflisted'* *'bl'* *'nobuflisted'* *'nobl'* *E85*
'buflisted' 'bl' boolean (default on)
Solution:
Only treat a tag as "h4 pseudo-heading" if it is the only tag in the
line. This is fragile, but in practice seems to get the right balance.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/gen_help_html.lua b/scripts/gen_help_html.lua
@@ -670,7 +670,7 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
return text
end
local in_heading = vim.list_contains({ 'h1', 'h2', 'h3' }, parent)
- local h4 = (not in_heading and get_indent(node_text()) > 8)
+ local h4 = not in_heading and not next_ and get_indent(node_text()) > 8 -- h4 pseudo-heading
local cssclass = h4 and 'help-tag-right' or 'help-tag'
local tagname = node_text(root:child(1), false)
if vim.tbl_count(stats.first_tags) < 2 then