feat: new default style and more
All checks were successful
Lint / shellcheck (push) Successful in 20s

This commit is contained in:
2026-03-19 15:35:14 +01:00
parent d8cf07ee2a
commit b7382a20ab
6 changed files with 156 additions and 44 deletions

View File

@@ -1,11 +1,20 @@
BEGIN { in_fence = 0; first_line = 0 }
BEGIN { in_fence = 0; first_line = 0; code_tag = "<code>" }
{
if (!in_fence && $0 ~ /^```/) {
in_fence = 1
first_line = 1
lang = $0
sub(/^```[[:space:]]*/, "", lang)
sub(/[[:space:]]*$/, "", lang)
if (lang != "") {
code_tag = "<code class=\"language-" lang "\">"
} else {
code_tag = "<code>"
}
next
}
if (in_fence && $0 ~ /^```[[:space:]]*$/) {
if (first_line) printf "%s", "<pre>" code_tag
print "</code></pre>"
in_fence = 0
next
@@ -14,8 +23,12 @@ BEGIN { in_fence = 0; first_line = 0 }
gsub(/&/, "\\&amp;"); gsub(/</, "\\&lt;"); gsub(/>/, "\\&gt;")
if (first_line) {
first_line = 0
if ($0 == "") next
print "<pre><code>" $0
printf "%s", "<pre>" code_tag
if ($0 == "") {
print ""
next
}
print $0
} else {
print
}
@@ -24,5 +37,8 @@ BEGIN { in_fence = 0; first_line = 0 }
}
}
END {
if (in_fence) print "</code></pre>"
if (in_fence) {
if (first_line) printf "%s", "<pre>" code_tag
print "</code></pre>"
}
}

View File

@@ -1,9 +1,20 @@
BEGIN { in_code = 0 }
/^ | / {
if (!in_code) { print "<pre><code>"; in_code = 1 }
sub(/^ | /, "", $0)
gsub(/&/, "\\&amp;"); gsub(/</, "\\&lt;"); gsub(/>/, "\\&gt;")
print; next
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)
gsub(/&/, "\\&amp;"); gsub(/</, "\\&lt;"); gsub(/>/, "\\&gt;")
print
next
}
if (in_code) {
print "</code></pre>"
in_code = 0
}
print
}
{ if (in_code) { print "</code></pre>"; in_code = 0 } print }
END { if (in_code) print "</code></pre>" }

View File

@@ -1,9 +1,17 @@
function replace_all(text, token, value, pos, token_len) {
function replace_all(text, token, value, pos, token_len, res) {
token_len = length(token)
res = ""
while ((pos = index(text, token)) > 0) {
text = substr(text, 1, pos - 1) value substr(text, pos + token_len)
res = res substr(text, 1, pos - 1) value
text = substr(text, pos + token_len)
}
return res text
}
BEGIN {
if (current_url != "") {
nav = replace_all(nav, "href=\"" current_url "\"", "href=\"" current_url "\" class=\"current-page\"")
}
return text
}
{