mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
docs(gen_help_html.lua): h4 pseudo-heading layout #30609
Problem: The right-aligned tag "pseudo-heading" layout mushes together with the left-aligned text. This is especially messy in a narrow viewport. Solution: Put a `<br>` on it. This is a hack until tree-sitter-vimdoc recognizes these pseudo-headings.
This commit is contained in:
parent
2f2f434613
commit
a0c64fe816
@ -665,13 +665,13 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
|
|||||||
code = ('<pre>%s</pre>'):format(trim(trim_indent(text), 2))
|
code = ('<pre>%s</pre>'):format(trim(trim_indent(text), 2))
|
||||||
end
|
end
|
||||||
return code
|
return code
|
||||||
elseif node_name == 'tag' then -- anchor
|
elseif node_name == 'tag' then -- anchor, h4 pseudo-heading
|
||||||
if root:has_error() then
|
if root:has_error() then
|
||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
local in_heading = vim.list_contains({ 'h1', 'h2', 'h3' }, parent)
|
local in_heading = vim.list_contains({ 'h1', 'h2', 'h3' }, parent)
|
||||||
local cssclass = (not in_heading and get_indent(node_text()) > 8) and 'help-tag-right'
|
local h4 = (not in_heading and get_indent(node_text()) > 8)
|
||||||
or 'help-tag'
|
local cssclass = h4 and 'help-tag-right' or 'help-tag'
|
||||||
local tagname = node_text(root:child(1), false)
|
local tagname = node_text(root:child(1), false)
|
||||||
if vim.tbl_count(stats.first_tags) < 2 then
|
if vim.tbl_count(stats.first_tags) < 2 then
|
||||||
-- Force the first 2 tags in the doc to be anchored at the main heading.
|
-- Force the first 2 tags in the doc to be anchored at the main heading.
|
||||||
@ -711,7 +711,7 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
|
|||||||
-- End the <span> container for tags in a heading.
|
-- End the <span> container for tags in a heading.
|
||||||
return string.format('%s</span>', s)
|
return string.format('%s</span>', s)
|
||||||
end
|
end
|
||||||
return s
|
return s .. (h4 and '<br>' or '') -- HACK: <br> avoids h4 pseudo-heading mushing with text.
|
||||||
elseif node_name == 'delimiter' or node_name == 'modeline' then
|
elseif node_name == 'delimiter' or node_name == 'modeline' then
|
||||||
return ''
|
return ''
|
||||||
elseif node_name == 'ERROR' then
|
elseif node_name == 'ERROR' then
|
||||||
@ -1151,6 +1151,7 @@ local function gen_css(fname)
|
|||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
float: right;
|
float: right;
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
.help-tag a,
|
.help-tag a,
|
||||||
.help-tag-right a {
|
.help-tag-right a {
|
||||||
|
Loading…
Reference in New Issue
Block a user