aboutsummaryrefslogtreecommitdiff
path: root/bin/compile-notes
blob: 1e55dcc5b22882b9a5e62b70efa8dea56910b8c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash
#
# Book compiler
#

# Parameters
BASENAME="`basename $0 | sed -e 's/\(.\)/\U\1/'`"
DIRNAME="`dirname $0`"
BASEDIR="$DIRNAME/.."
OUTPUT="${1:-notes}"
REVISION="$2"
DATE="$3"

# Remove any dangling output files
rm -f $OUTPUT.md

# Content
find content/notes -type f | grep '\.md$' | sort | while read file; do
  cat $file >> $OUTPUT.md
  echo "" >> $OUTPUT.md
done

# Bibliography section
echo "# Bibliografia" >> $OUTPUT.md

# Revision information
sed -i -e "s|%%revision%%|$REVISION|g" -e "s|%%date%%|$REVISION|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 -s $OUTPUT.md notes.Rmd