From 670925a84fefafd84b3daa55ae14811866ae8743 Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Mon, 23 Oct 2023 21:47:43 +0530 Subject: [PATCH] Meta: Add anchors to headings of man pages --- Meta/Websites/man.serenityos.org/add-anchors.lua | 14 ++++++++++++++ Meta/build-manpages-website.sh | 1 + 2 files changed, 15 insertions(+) create mode 100644 Meta/Websites/man.serenityos.org/add-anchors.lua diff --git a/Meta/Websites/man.serenityos.org/add-anchors.lua b/Meta/Websites/man.serenityos.org/add-anchors.lua new file mode 100644 index 00000000000..18e7f8a0466 --- /dev/null +++ b/Meta/Websites/man.serenityos.org/add-anchors.lua @@ -0,0 +1,14 @@ +function Header(header) + local level = header.level + local identifier = header.identifier + local anchor = pandoc.RawInline('html', '#') + + -- 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 + \ No newline at end of file diff --git a/Meta/build-manpages-website.sh b/Meta/build-manpages-website.sh index f46dece75dc..6d2dd95709d 100755 --- a/Meta/build-manpages-website.sh +++ b/Meta/build-manpages-website.sh @@ -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}" &