feat: new default style and more
All checks were successful
Lint / shellcheck (push) Successful in 20s
All checks were successful
Lint / shellcheck (push) Successful in 20s
This commit is contained in:
@@ -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(/&/, "\\&"); gsub(/</, "\\<"); gsub(/>/, "\\>")
|
||||
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>"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user