Jan Ulrich Hasecke
2022-07-20 6a32e46d16a09645bd47734cc7d3e7912ef305be
commit | author | age
6a4200 1 #!/bin/sh
JUH 2
3 case $(uname) in
4     "Darwin")
5         readlink() {
6             greadlink ${@}
7         }
8         ;;
9     "Linux")
10         ;;
11     *)
12         echo "Unsupported platform." >&2
13         exit 1
14 esac
15
16 basedir=$(readlink -f $(dirname ${0}))
17 cd ${basedir}
18
19 if [ ${#} -ne 1 ]; then
20    echo "Invokation: ${0} <project>" >&2
21    exit 1
22 fi
23
24 project=${1}
25
26 if [ ! -e ${basedir}/source/${project}/${project}.md ]; then
27    echo "Project »${project}« not found." >&2
28    exit 1
29 fi
30
31 project_pdf_settings=${basedir}/control/${project}/pdf/settings.yml
32 default_pdf_settings=${basedir}/control/default/pdf/settings.yml
33
34 project_html_settings=${basedir}/control/${project}/html/settings.yml
35 default_html_settings=${basedir}/control/default/html/settings.yml
36
37 project_epub_settings=${basedir}/control/${project}/epub/settings.yml
38 default_epub_settings=${basedir}/control/default/epub/settings.yml
39
40 project_txt_settings=${basedir}/control/${project}/txt/settings.yml
41 default_txt_settings=${basedir}/control/default/txt/settings.yml
42
43 if test -e ${project_pdf_settings}; then
44    settings_pdf=${project_pdf_settings}
45 else
46    settings_pdf=${default_pdf_settings}
47 fi
48
49 if test -e ${project_html_settings}; then
50    settings_html=${project_html_settings}
51 else
52    settings_html=${default_html_settings}
53 fi
54
55 if test -e ${project_epub_settings}; then
56    settings_epub=${project_epub_settings}
57 else
58    settings_epub=${default_epub_settings}
59 fi
60
61 if test -e ${project_txt_settings}; then
62    settings_txt=${project_txt_settings}
63 else
64    settings_txt=${default_txt_settings}
65 fi
66
67 cd ${basedir}/source/${project}
68 rm -f ${project}.tex
69 pandoc $(cat ${settings_pdf}) --output=${project}.tex ${project}.md
70 context --purgeall --result=${project}.pdf ${project}.tex
71 pandoc $(cat ${settings_html}) --output=${project}.html ${project}.md