feat: colour palettes
All checks were successful
Lint / shellcheck (push) Successful in 17s

This commit is contained in:
2026-04-01 14:23:12 +02:00
parent 69bd5832e7
commit 009877ae76
30 changed files with 446 additions and 85 deletions

View File

@@ -8,7 +8,7 @@ BEGIN {
if ($0 ~ /^<pre>/) {
if (!in_pre) in_pre = 1
}
if (!in_pre && $0 ~ /^:[ \t]+[^ \t]/) {
if (!in_dl) {
in_dl = 1
@@ -24,7 +24,7 @@ BEGIN {
def_text = $0
sub(/^:[ \t]+/, "", def_text)
print "<dd>" def_text "</dd>"
if ($0 ~ /<\/pre>/) {
if (in_pre) in_pre = 0
}
@@ -46,7 +46,7 @@ BEGIN {
prev_line = $0
has_prev = 1
}
if ($0 ~ /<\/pre>/) {
if (in_pre) in_pre = 0
}

View File

@@ -8,7 +8,7 @@ BEGIN { fn_count = 0 }
text = substr($0, id_end + 2)
# Trim leading space
sub(/^[ \t]+/, "", text)
fn_ids[++fn_count] = id
fn_texts[id] = text
next
@@ -21,19 +21,19 @@ BEGIN { fn_count = 0 }
END {
for (i = 1; i <= line_count; i++) {
line = lines[i]
for (j = 1; j <= fn_count; j++) {
id = fn_ids[j]
marker = "[^" id "]"
repl = "<sup><a href=\"#fn:" id "\" id=\"fnref:" id "\">" id "</a></sup>"
while ((pos = index(line, marker)) > 0) {
line = substr(line, 1, pos - 1) repl substr(line, pos + length(marker))
}
}
print line
}
if (fn_count > 0) {
print "<hr />"
print "<section class=\"footnotes\">"

View File

@@ -2,7 +2,7 @@ BEGIN { in_code = 0; in_html_pre = 0 }
{
if ($0 ~ /<pre>/) in_html_pre = 1
if ($0 ~ /<\/pre>/) { in_html_pre = 0; if (in_code) { print "</code></pre>"; in_code = 0 }; print; next }
if (!in_html_pre && $0 ~ /^(\t| )/) {
if (!in_code) { printf "%s", "<pre><code>"; in_code = 1 }
sub(/^(\t| )/, "", $0)
@@ -10,7 +10,7 @@ BEGIN { in_code = 0; in_html_pre = 0 }
print
next
}
if (in_code) {
print "</code></pre>"
in_code = 0

View File

@@ -30,7 +30,7 @@ BEGIN {
# get indentation level
match(line, /^[ \t]*/)
indent = RLENGTH
if (depth == 0 || indent > cur_indent[depth]) {
depth++
cur_indent[depth] = indent

View File

@@ -140,18 +140,18 @@ function css_highlight_line(line, m, prop, val) {
match(line, /:[[:space:]]*/)
sep_pos = RSTART
sep_len = RLENGTH
pre_sep = substr(line, 1, sep_pos - 1)
sep = substr(line, sep_pos, sep_len)
post_sep = substr(line, sep_pos + sep_len)
match(pre_sep, /--?[A-Za-z0-9_-]+/)
prop_pos = RSTART
prop_len = RLENGTH
indent = substr(pre_sep, 1, prop_pos - 1)
prop_name = substr(pre_sep, prop_pos, prop_len)
if (match(post_sep, /;[[:space:]]*$/)) {
val_part = substr(post_sep, 1, RSTART - 1)
suffix = substr(post_sep, RSTART)
@@ -159,11 +159,11 @@ function css_highlight_line(line, m, prop, val) {
val_part = post_sep
suffix = ""
}
prop = "<span class=\"tok-prop\">" prop_name "</span>"
gsub(/var\(--[A-Za-z0-9_-]+\)/, "<span class=\"tok-var\">&</span>", val_part)
val = "<span class=\"tok-val\">" val_part "</span>"
return indent prop sep val suffix
}

View File

@@ -46,14 +46,9 @@ function mask(s, t) {
while (match(substr(line, p), /`+/)) {
pstart = p + RSTART - 1
plen = RLENGTH
if (plen >= 3) {
out = out substr(line, p, pstart - p + plen)
p = pstart + plen
continue
}
# Found 1 or 2 backticks at pstart
# Search for closing marker
# Found backtick sequence at pstart
# Search for closing marker of same length
marker = substr(line, pstart, plen)
tail = substr(line, pstart + plen)
mpos = index(tail, marker)
@@ -65,11 +60,11 @@ function mask(s, t) {
p = pstart + plen
continue
}
# Found match!
content = substr(tail, 1, mpos - 1)
out = out substr(line, p, pstart - p)
if (plen == 2 && substr(content, 1, 1) == " " && substr(content, length(content), 1) == " ") {
if (plen >= 2 && substr(content, 1, 1) == " " && substr(content, length(content), 1) == " ") {
content = substr(content, 2, length(content) - 2)
}
out = out "<code>" mask(content) "</code>"

View File

@@ -56,7 +56,7 @@ BEGIN { in_plain = 0; in_script_style = 0 }
script_start = RSTART; script_len = RLENGTH
pos_style = match(tolower(tmp_line), /<style([ >]|$)/)
style_start = RSTART; style_len = RLENGTH
if (pos_script == 0 && pos_style == 0) {
out2 = out2 tmp_line
break

View File

@@ -5,7 +5,7 @@ BEGIN {
{
if ($0 ~ /<pre>/) in_pre = 1
if (in_pre) {
if (in_p) { print "</p>"; in_p = 0 }
print

View File

@@ -18,17 +18,17 @@ BEGIN {
if (title_end > 0) {
title = substr(title_str, 1, title_end - 1)
gsub(/<[^>]+>/, "", title)
# extract id
id_start = match($0, /id="[^"]*"/)
if (id_start > 0) {
id_str = substr($0, id_start + 4)
id_end = index(id_str, "\"")
id = substr(id_str, 1, id_end - 1)
# what tag? level
level = substr($0, match($0, /<h[23]/) + 2, 1)
if (level == "2") {
toc_str = toc_str "<li class=\"toc-h2\"><a href=\"#" id "\">" title "</a></li>\n"
} else if (level == "3") {

View File

@@ -1,6 +1,6 @@
BEGIN {
BEGIN {
new_title = ENVIRON["AWK_NEW_TITLE"]
done = 0
done = 0
}
/^title[[:space:]]*=/ {
print "title = \"" new_title "\""