the repository which powers this website
waow
| -rwxr-xr-x | filters/syntax-highlighting-shiki.sh | 4 | ||||
| -rw-r--r-- | themed/themed.in.css | 1 | ||||
| -rw-r--r-- | themed/tree.html | 26 |
3 files changed, 31 insertions, 0 deletions
diff --git a/filters/syntax-highlighting-shiki.sh b/filters/syntax-highlighting-shiki.sh index 2f2a281d..f42ccdeb 100755 --- a/filters/syntax-highlighting-shiki.sh +++ b/filters/syntax-highlighting-shiki.sh @@ -8,6 +8,9 @@ EXTENSION="${BASENAME##*.}" # map Makefile and Makefile.* to .mk [ "${BASENAME%%.*}" = "Makefile" ] && EXTENSION=mk +if [[ "$EXTENSION" = "md" ]]; then + bash "$(dirname $0)/about-formatting.sh" $1 +else echo -n '<div id="code-block"><pre style="background-color: #1f2430; color: #cccac2"><code id="contents">' sed 's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g' @@ -30,3 +33,4 @@ o.innerHTML = (await highlighter.codeToHtml(i.innerText, { </script> EOF +fi diff --git a/themed/themed.in.css b/themed/themed.in.css index ff4f4d1c..b8eb6dc8 100644 --- a/themed/themed.in.css +++ b/themed/themed.in.css @@ -14,6 +14,7 @@ } .rendered-file { + font-family: Verdana, Helvetica, Ubuntu, sans-serif; a { @apply hover:underline; } diff --git a/themed/tree.html b/themed/tree.html index 8b00a96f..1a5bd8fa 100644 --- a/themed/tree.html +++ b/themed/tree.html @@ -1,4 +1,21 @@ {! #include "../ui-tree.h" !} +{! + +static int match_extension(const char *filename, const char *ext) +{ + int prefixlen = strlen(filename) - strlen(ext); + + /* + * We need 1 character for the '.', and 1 character to ensure that the + * prefix is non-empty (k.e., we don't match .tar.gz with no actual + * filename). + */ + if (prefixlen < 2 || filename[prefixlen - 1] != '.') + return 0; + return !strcmp(filename + prefixlen, ext); +} +!} + {% block repo_navigation_breadcrumbs %} <div class="px-3"> @@ -48,6 +65,15 @@ <div class="text-[#F07178]"> blob size ({{ size / 1024|%ld }}KB) exceeds display size limit ({{ ctx.cfg.max_blob_size|%d }}KB). </div> + {% elif match_extension(basename, "md") %} + <div class="rendered-file p-1 border border-[#333A45] text-[#CCCAC2] rounded-md"> + {! + cgit_open_filter(ctx.repo->about_filter, xstrdup(basename)); + html_raw(buf, size); + cgit_close_filter(ctx.repo->about_filter); + free(buf); + !} + </div> {% else %} <div class="rendered-blob overflow-x-auto border border-[#333A45] rounded-md"> {! |