From 6d68793fa0e50c58a5ab90b6de5ecf8ce061dc04 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 14:42:23 -0700 Subject: Print line number anchors through one helper --- source/ui-shared.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source/ui-shared.c') diff --git a/source/ui-shared.c b/source/ui-shared.c index 5e2a9de..81db404 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -1317,6 +1317,22 @@ void cgit_print_date(timestamp_t date, int tz) html(""); } +void cgit_print_line_anchors(size_t first, size_t last) +{ + struct strbuf numbers = STRBUF_INIT; + size_t lineno; + + for (lineno = first; lineno <= last; lineno++) { + strbuf_addf(&numbers, "%zu\n", lineno, lineno, lineno); + if (numbers.len >= HTML_BATCH) { + html_raw(numbers.buf, numbers.len); + strbuf_reset(&numbers); + } + } + html_raw(numbers.buf, numbers.len); + strbuf_release(&numbers); +} + void cgit_print_person(const char *name, const char *email, const char *origin, int show_email) { cgit_open_filter(ctx.repo->email_filter, email ? email : "", origin); -- cgit