From fdb0633ea66879ffed8b5f3a9a37cf42e27a2113 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 10:36:39 -1000 Subject: Never give two headings the same anchor A repeat's count was keyed on the bare text, so a heading whose text already ended in that count took the same anchor, as "Twice 1" did after two of "Twice", and "About 1" after "About". A link to either then landed on the first. The count now goes on up past any anchor already handed out, the way GitHub's slugger does. --- tests/extensions/test-about-render.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/extensions/test-about-render.lua b/tests/extensions/test-about-render.lua index b9284c4..6f54805 100644 --- a/tests/extensions/test-about-render.lua +++ b/tests/extensions/test-about-render.lua @@ -86,6 +86,16 @@ h.contains("a repeated anchor is counted", out, "

Twice

") +out = render("README.md", "# Cgit\n# Header") +h.contains("nor any other id of the page", out, "

Cgit

Header

") + +out = render("README.md", "# Twice\n# Twice\n# Twice 1") +h.contains("a count never gives an anchor a heading already took", out, + "

Twice

Twice 1

") + +out = render("README.md", "# About\n# About 1") +h.contains("and the same holds past an id of the page", out, "

About

About 1

") + out = render("README.md", "# ???") h.contains("a heading of punctuation gets no anchor", out, "

???

") -- cgit 2.12.1