|
| 1 | +#!/bin/sh |
| 2 | +set -x |
| 3 | + |
| 4 | +function system { |
| 5 | + "$@" |
| 6 | + if [ $? -ne 0 ]; then |
| 7 | + echo "make.sh: unsuccessful command $@" |
| 8 | + echo "abort!" |
| 9 | + exit 1 |
| 10 | + fi |
| 11 | +} |
| 12 | + |
| 13 | +if [ $# -eq 0 ]; then |
| 14 | +echo 'bash make.sh slides1|slides2' |
| 15 | +exit 1 |
| 16 | +fi |
| 17 | + |
| 18 | +name=$1 |
| 19 | +rm -f *.tar.gz |
| 20 | + |
| 21 | +opt="--encoding=utf-8" |
| 22 | +opt= |
| 23 | + |
| 24 | +rm -f *.aux |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | +# Plain HTML documents |
| 29 | +html=${name} |
| 30 | +system doconce format html $name --pygments_html_style=default --html_style=bloodish --html_links_in_new_window --html_output=$html $opt |
| 31 | +system doconce split_html $html.html --method=space10 |
| 32 | + |
| 33 | +# Bootstrap style |
| 34 | +html=${name}-bs |
| 35 | +system doconce format html $name --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=$html $opt |
| 36 | +system doconce split_html $html.html --method=split --pagination --nav_button=bottom |
| 37 | + |
| 38 | +# IPython notebook |
| 39 | +system doconce format ipynb $name $opt |
| 40 | + |
| 41 | + |
| 42 | +# Ordinary plain LaTeX document |
| 43 | +system doconce format pdflatex $name --print_latex_style=trac --latex_admon=paragraph $opt |
| 44 | +system doconce ptex2tex $name envir=verbatim |
| 45 | +# Add special packages |
| 46 | +doconce subst "% Add user's preamble" "\g<1>\n\\usepackage{simplewick}" $name.tex |
| 47 | +doconce replace 'section{' 'section*{' $name.tex |
| 48 | +pdflatex -shell-escape $name |
| 49 | +pdflatex -shell-escape $name |
| 50 | +mv -f $name.pdf ${name}.pdf |
| 51 | +cp $name.tex ${name}.tex |
| 52 | + |
| 53 | +# Publish |
| 54 | +dest=../../../../Projects/2025 |
| 55 | +if [ ! -d $dest/$name ]; then |
| 56 | +mkdir $dest/$name |
| 57 | +mkdir $dest/$name/pdf |
| 58 | +mkdir $dest/$name/html |
| 59 | +mkdir $dest/$name/ipynb |
| 60 | +fi |
| 61 | +cp ${name}*.tex $dest/$name/pdf |
| 62 | +cp ${name}*.pdf $dest/$name/pdf |
| 63 | +cp -r ${name}*.html ._${name}*.html $dest/$name/html |
| 64 | + |
| 65 | +# Figures: cannot just copy link, need to physically copy the files |
| 66 | +if [ -d fig-${name} ]; then |
| 67 | +if [ ! -d $dest/$name/html/fig-$name ]; then |
| 68 | +mkdir $dest/$name/html/fig-$name |
| 69 | +fi |
| 70 | +cp -r fig-${name}/* $dest/$name/html/fig-$name |
| 71 | +fi |
| 72 | + |
| 73 | +cp ${name}.ipynb $dest/$name/ipynb |
| 74 | +ipynb_tarfile=ipynb-${name}-src.tar.gz |
| 75 | +if [ ! -f ${ipynb_tarfile} ]; then |
| 76 | +cat > README.txt <<EOF |
| 77 | +This IPython notebook ${name}.ipynb does not require any additional |
| 78 | +programs. |
| 79 | +EOF |
| 80 | +tar czf ${ipynb_tarfile} README.txt |
| 81 | +fi |
| 82 | +cp ${ipynb_tarfile} $dest/$name/ipynb |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
0 commit comments