From c1862d78f704f9c7f7cec19c8f0d03d632c11115 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 18 Nov 2026 11:56:32 +0000 Subject: cgit-about-filter: link headings instead of a link symbol The heading itself links to itself, underlined on hover. Clicking the heading the #fragment points to removes the fragment again, and with it the highlight. --- .../simple/cgit-about-filter/cgit-about-filter.lua | 33 ++++++++++++++++------ 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'pkgs/simple/cgit-about-filter') diff --git a/pkgs/simple/cgit-about-filter/cgit-about-filter.lua b/pkgs/simple/cgit-about-filter/cgit-about-filter.lua index f317c54..7b36226 100644 --- a/pkgs/simple/cgit-about-filter/cgit-about-filter.lua +++ b/pkgs/simple/cgit-about-filter/cgit-about-filter.lua @@ -227,15 +227,27 @@ local function slug(content) return (text:lower():gsub("[^%w%s_%-\128-\255]", ""):gsub("%s", "-")) end --- A chain link, after each heading, linking to it. -local anchor = [[]] - -local anchor_style = [[ +-- Headings link to themselves, underlined on hover by cgit.css. Clicking +-- the heading that is the #fragment removes the fragment again. Setting +-- location.hash is what makes :target forget the heading; +-- history.replaceState alone doesn't. +local heading_links = [[ + ]] -- Give headings ids, so links to #fragments work. A repeated id gets -1, @@ -253,7 +265,10 @@ local function heading_ids(output) else seen[id] = 0 end - return string.format('%s' .. anchor .. '', level, id, content, id, level) + if not content:find("%s', id, content) + end + return string.format('%s', level, id, content, level) end)) end @@ -421,7 +436,7 @@ local function close() output = heading_ids(output) if output:find('", 1, true) then emit(table_style) -- cgit v1.3.1