Meta: Add anchors to headings of man pages

This commit is contained in:
Gurkirat Singh 2023-10-23 21:47:43 +05:30 committed by Sam Atkins
parent 82ce4acfe5
commit 670925a84f
Notes: sideshowbarker 2024-07-17 08:45:34 +09:00
2 changed files with 15 additions and 0 deletions

View file

@ -0,0 +1,14 @@
function Header(header)
local level = header.level
local identifier = header.identifier
local anchor = pandoc.RawInline('html', '<a style="margin-right: 15px" href="#' .. identifier .. '">#</a>')
-- Create a list of inline elements containing the anchor and header content
local new_content = pandoc.List({anchor})
for _, elem in ipairs(header.content) do
new_content:insert(elem)
end
return pandoc.Header(level, new_content, identifier)
end

View file

@ -42,6 +42,7 @@ for md_file in $(find "${MAN_DIR}" -iname '*.md' | ${SORT}); do
pandoc -f gfm -t html5 -s \
-B Meta/Websites/man.serenityos.org/banner-preamble.inc \
--lua-filter=Meta/convert-markdown-links.lua \
--lua-filter=Meta/Websites/man.serenityos.org/add-anchors.lua \
--metadata title="${name}(${section_number}) - SerenityOS man pages" \
-o "${output_file}" \
"${md_file}" &