commit 126ccb7c65708785c5747c0ca9ab0c8484c6e501
parent 33ba59ca4d25635d6e5743869a34251646dcbc59
Author: St John Karp <contact@stjo.hn>
Date: Sat, 27 Jun 2020 09:08:42 -0500
Move Prolog commands into their own scripts
Moved the generate and ungenerate calls to Prolog into their
own scripts. This allows them to be formatted properly when editing
because they're no longer technically strings, and also lets us
skip another sed step that we can replace with parameter expansion.
Diffstat:
4 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/generate_html.sh b/generate_html.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env sh
+
+echo "$1"
+
+swipl --traditional --quiet -l parse_entry.pl -g "consult('$2/site.pl'), generate_entry('$2/source/$1')." |
+ smartypants \
+ > "$2/output/${1%%.md}.html"
diff --git a/generate_markdown.sh b/generate_markdown.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env sh
+
+echo "$1"
+
+swipl --traditional --quiet -l parse_entry.pl -g "consult('$2/site.pl'), parse_entry('$2/output/$1')." \
+ > "$2/source/${1%%.html}.md"
diff --git a/squeeze.sh b/squeeze.sh
@@ -13,11 +13,7 @@ rsync --archive --delete --verbose \
# Parse and create all the HTML files.
find "$SOURCE_PATH" -type f -name "*.md" -printf "%P\0" |
- sed "s|\.md||g" |
- xargs --null --max-procs 99 -I % sh -c "echo '%' &&
- swipl --traditional --quiet -l parse_entry.pl -g \"consult('$SITE_PATH/site.pl'), generate_entry('$SOURCE_PATH/%.md').\" |
- smartypants \
- > \"$OUTPUT_PATH/%.html\""
+ xargs --null --max-procs 99 -I % sh generate_html.sh "%" "$SITE_PATH"
# Generate the RSS feed.
mkdir -p "$OUTPUT_PATH/feeds"
diff --git a/unsqueeze.sh b/unsqueeze.sh
@@ -14,10 +14,7 @@ rsync --archive --delete --verbose \
# Parse and create all the Markdown files.
find "$OUTPUT_PATH" -type f -name "*.html" -printf "%P\0" |
- sed "s|\.html||g" |
- xargs --null --max-procs 99 -I % sh -c "echo '%' &&
- swipl --traditional --quiet -l parse_entry.pl -g \"consult('$SITE_PATH/site.pl'), parse_entry('$OUTPUT_PATH/%.html').\" \
- > \"$SOURCE_PATH/%.md\""
+ xargs --null --max-procs 99 -I % sh generate_markdown.sh "%" "$SITE_PATH"
# Unsmarten the punctuation.
find "$SOURCE_PATH" -type f -name "*.md" \