Jan Ulrich Hasecke
2022-07-21 b462a126a36de0f6a0dc69ac127c3984a0ff9480
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh
 
case $(uname) in
    "Darwin")
        readlink() {
            greadlink ${@}
        }
        ;;
    "Linux")
        ;;
    *)
        echo "Unsupported platform." >&2
        exit 1
esac
 
basedir=$(readlink -f $(dirname ${0}))
cd ${basedir}
 
if [ ${#} -ne 1 ]; then
   echo "Invokation: ${0} <project>" >&2
   exit 1
fi
 
project=${1}
 
if [ ! -e ${basedir}/source/${project}/${project}.md ]; then
   echo "Project »${project}« not found." >&2
   exit 1
fi
 
project_pdf_settings=${basedir}/control/${project}/pdf/settings.yml
default_pdf_settings=${basedir}/control/default/pdf/settings.yml
 
project_html_settings=${basedir}/control/${project}/html/settings.yml
default_html_settings=${basedir}/control/default/html/settings.yml
 
project_epub_settings=${basedir}/control/${project}/epub/settings.yml
default_epub_settings=${basedir}/control/default/epub/settings.yml
 
project_txt_settings=${basedir}/control/${project}/txt/settings.yml
default_txt_settings=${basedir}/control/default/txt/settings.yml
 
if test -e ${project_pdf_settings}; then
   settings_pdf=${project_pdf_settings}
else
   settings_pdf=${default_pdf_settings}
fi
 
if test -e ${project_html_settings}; then
   settings_html=${project_html_settings}
else
   settings_html=${default_html_settings}
fi
 
if test -e ${project_epub_settings}; then
   settings_epub=${project_epub_settings}
else
   settings_epub=${default_epub_settings}
fi
 
if test -e ${project_txt_settings}; then
   settings_txt=${project_txt_settings}
else
   settings_txt=${default_txt_settings}
fi
 
cd ${basedir}/source/${project}
rm -f ${project}.tex
pandoc $(cat ${settings_pdf}) --output=${project}.tex ${project}.md
context --purgeall --result=${project}.pdf ${project}.tex
pandoc $(cat ${settings_html}) --output=${project}.html ${project}.md