docs(gen_help_html.lua): h4 pseudo-heading layout

Problem:
The <br> hack in a0c64fe816 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.
This commit is contained in:
Justin M. Keyes 2024-10-01 12:51:16 +02:00
parent a0c64fe816
commit 72892aab06

View File

@ -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