summaryrefslogtreecommitdiff
path: root/src/conf
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-04-09 17:10:45 -0300
committerEuAndreh <eu@euandre.org>2025-04-09 17:10:45 -0300
commit0d29cc71734dbc96e0e76ccdaa640aba957f3ec8 (patch)
tree6e76c30b021c3bdf1f48a91d69d6f3c8ea98cedc /src/conf
parentsrc/links: Add new working subcommand (diff)
downloadmkwb-0d29cc71734dbc96e0e76ccdaa640aba957f3ec8.tar.gz
mkwb-0d29cc71734dbc96e0e76ccdaa640aba957f3ec8.tar.xz
src/conf: Extract embedded-config from document header variables
Diffstat (limited to 'src/conf')
-rwxr-xr-xsrc/conf15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/conf b/src/conf
index fa753e9..b423e23 100755
--- a/src/conf
+++ b/src/conf
@@ -92,13 +92,14 @@ eval "$(assert-arg -- "$FILENAME" 'FILENAME')"
trap 'rm -f -- "$FILENAME".embedded-config' EXIT
-{
- if head -n1 -- "$FILENAME" | grep -q '^////$'; then
- awk 'sep > 1 {exit}; /^\/{4}$/ { sep++; next } { print }' \
- "$FILENAME"
- fi
-} > "$FILENAME".embedded-config
-. "$(realpath -- "$FILENAME".embedded-config)"
+awk '
+$0 == "" {exit}
+/^= / {next}
+{ printf "export %s=\"%s\"\n",
+ substr($1, 2, length($1) - 2),
+ substr($0, length($1) + 2) }
+' "$FILENAME" > "$FILENAME".embedded-config
+. ./"$FILENAME".embedded-config
is_article() {
printf '%s\n' "$FILENAME" | grep -qE \