aboutsummaryrefslogtreecommitdiff
path: root/bin/compile-book
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2024-06-09 11:28:11 +0100
committerSilvio Rhatto <rhatto@riseup.net>2024-06-09 11:28:11 +0100
commit08fe9f739dcf1570ce0321db979a410fe61ebd60 (patch)
tree05b98e7f6036682d86be2f66873a1807c753c8db /bin/compile-book
parentad5dc9ae41051b5de11904620ea6f973cdf306ad (diff)
downloadbookup-08fe9f739dcf1570ce0321db979a410fe61ebd60.tar.gz
bookup-08fe9f739dcf1570ce0321db979a410fe61ebd60.tar.bz2
Feat: improved compilation procedures
Diffstat (limited to 'bin/compile-book')
-rwxr-xr-xbin/compile-book58
1 files changed, 58 insertions, 0 deletions
diff --git a/bin/compile-book b/bin/compile-book
new file mode 100755
index 0000000..42f7f67
--- /dev/null
+++ b/bin/compile-book
@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+#
+# Book compiler
+#
+
+# Parameters
+BASENAME="`basename $0 | sed -e 's/\(.\)/\U\1/'`"
+DIRNAME="`dirname $0`"
+BASEDIR="$DIRNAME/.."
+OUTPUT="${1:-book}"
+REVISION="$2"
+DATE="$3"
+
+# Remove any dangling output files
+rm -f $OUTPUT.md $OUTPUT.Rmd
+
+# Bookup config
+cat _bookup.yml >> $OUTPUT.md ; echo "" >> $OUTPUT.md
+
+# Bibliography
+cat _biblio.yml >> $OUTPUT.md ; echo "" >> $OUTPUT.md
+
+# YAML headers
+for file in $BASEDIR/structure/00*.yml; do
+ cat $file >> $OUTPUT.md
+ echo "---" >> $OUTPUT.md
+done
+
+# Markdown headers
+for file in $BASEDIR/structure/00*.md; do
+ cat $file >> $OUTPUT.md
+ echo "" >> $OUTPUT.md
+done
+
+# Sections
+find content/sections -type f | grep '\.md$' | sort | while read file; do
+ cat $file >> $OUTPUT.md
+ echo "" >> $OUTPUT.md
+ cat $BASEDIR/templates/references.md >> $OUTPUT.md
+ echo "" >> $OUTPUT.md
+done
+
+# Footers
+for file in $BASEDIR/structure/99*.md; do
+ cat $file >> $OUTPUT.md
+ echo "" >> $OUTPUT.md
+done
+
+# Revision information
+sed -i -e "s|%%revision%%|$REVISION|g" -e "s|%%date%%|$DATE|g" $OUTPUT.md
+
+# Post-processing
+if [ -e "snippets/terminology.sed" ]; then
+ sed -i -f snippets/terminology.sed $OUTPUT.md
+fi
+
+# Symlink as a Bookdown source
+ln -sf $OUTPUT.md $OUTPUT.Rmd