aboutsummaryrefslogtreecommitdiff
path: root/v2
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-09-02 12:53:00 -0300
committerEuAndreh <eu@euandre.org>2022-09-02 12:53:00 -0300
commit4bfa46a2fb0c1c33bc090a0900cf729317b5d092 (patch)
tree1673e5c50c988b85ff1cb66ac196179606e94857 /v2
parentGenerate .entry-content and .entry-env when building HTML (diff)
downloadeuandre.org-4bfa46a2fb0c1c33bc090a0900cf729317b5d092.tar.gz
euandre.org-4bfa46a2fb0c1c33bc090a0900cf729317b5d092.tar.xz
v2/src/bin/extract: Include FILENAME as an argument (and output)
Diffstat (limited to 'v2')
-rw-r--r--v2/dynamic.mk4
-rwxr-xr-xv2/src/bin/extract18
2 files changed, 14 insertions, 8 deletions
diff --git a/v2/dynamic.mk b/v2/dynamic.mk
index 01b8917..b9cd5fc 100644
--- a/v2/dynamic.mk
+++ b/v2/dynamic.mk
@@ -25,10 +25,10 @@ include generated.mk
sh src/development/genhtml.sh $< > $@
.md.entry-content:
- extract -t content < $? > $@
+ extract -t content $? > $@
.md.entry-env:
- extract -t env < $? > $@
+ extract -t env $? > $@
pastebins.html = $(pastebins.md:.md=.html)
diff --git a/v2/src/bin/extract b/v2/src/bin/extract
index ce4b115..4380be7 100755
--- a/v2/src/bin/extract
+++ b/v2/src/bin/extract
@@ -5,7 +5,7 @@ set -eu
usage() {
cat <<-'EOF'
Usage:
- extract -t TYPE < STDIN
+ extract -t TYPE FILENAME
extract -h
EOF
}
@@ -17,21 +17,24 @@ help() {
-t TYPE the type of extraction to perform ("content" or "env")
-h, --help show this message
+ FILENAME the name of the input file, also to be used as
+ URL.
+
Separate the content from the "frontmatter", and emit the
- selected one.
+ selected one, given the FILENAME.
Examples:
Get the content:
- $ extract -t content < src/file.md > src/file.entry-content
+ $ extract -t content src/file.md > src/file.entry-content
Get the "frontmatter":
- $ extract -t env < src/f.md > src/f.entry-env
+ $ extract -t env src/f.md > src/f.entry-env
EOF
}
@@ -71,6 +74,8 @@ done
shift $((OPTIND - 1))
+FILENAME="${1:-}"
+eval "$(assert-arg "$FILENAME" 'FILENAME')"
eval "$(assert-arg "$TYPE" '-t TYPE')"
@@ -79,7 +84,7 @@ case "$TYPE" in
awk '
separator >= 2
/^---$/ { separator++ }
- '
+ ' "$FILENAME"
;;
env)
awk '
@@ -92,7 +97,8 @@ case "$TYPE" in
}
{ print }
- '
+ ' "$FILENAME"
+ printf "FILENAME='%s'\n" "$FILENAME"
;;
*)
printf 'Bad value for TYPE: "%s".\n\n' \