Diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Print line number anchors through one helper
Diffstat (limited to '')
-rw-r--r--source/ui-shared.c16
1 file changed, 16 insertions, 0 deletions
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("</time>");
}
+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, "<a id='n%zu' href='#n%zu'>%zu</a>\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);