From 39c8cd2ae5eadec313661227055fe6d07246ca4e Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Wed, 15 Jul 2026 11:12:30 -1000 Subject: Render README markdown in the browser cgit had no markdown support of its own, so a readme was rendered through an external python filter or not at all. Escaping the source and formatting it in cgit.js keeps the work in the browser like the blob highlighter, and the page stays readable as plain text without scripting. --- source/ui-blob.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source/ui-blob.c') diff --git a/source/ui-blob.c b/source/ui-blob.c index bc91656..7720a28 100644 --- a/source/ui-blob.c +++ b/source/ui-blob.c @@ -67,7 +67,7 @@ done: return walk_tree_ctx.found_path; } -int cgit_print_file(char *path, const char *head, int file_only) +int cgit_print_file(char *path, const char *head, int file_only, int html_escape) { struct object_id oid; enum object_type type; @@ -106,7 +106,10 @@ int cgit_print_file(char *path, const char *head, int file_only) if (!buf) return -1; buf[size] = '\0'; - html_raw(buf, size); + if (html_escape) + html_txt(buf); + else + html_raw(buf, size); free(buf); return 0; } -- cgit v2.8.0