52 modularized build script into functions and added possibility to have markdown appendices
This commit is contained in:
		| @@ -1,4 +0,0 @@ | |||||||
| %!TEX root = ../main.tex |  | ||||||
|  |  | ||||||
| \section{Example} |  | ||||||
| \label{app:example} |  | ||||||
| @@ -1,5 +1,7 @@ | |||||||
| %!TEX root = ../main.tex | %!TEX root = ../main.tex | ||||||
|  |  | ||||||
| % input the appendix files here like this: | % input the appendix files here like this: | ||||||
| \input{appendix/01_example.tex} | % \input{appendix/01_example.tex} | ||||||
| \newpage | % \newpage | ||||||
|  | % when using markdown based appendices, they'll be generated to appendix/generated/${filename}.tex | ||||||
|  | % appendices need to be \sections! | ||||||
|   | |||||||
							
								
								
									
										0
									
								
								appendix/generated/.gitkeep
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								appendix/generated/.gitkeep
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										95
									
								
								build.sh
									
									
									
									
									
								
							
							
						
						
									
										95
									
								
								build.sh
									
									
									
									
									
								
							| @@ -1,25 +1,94 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
|  |  | ||||||
| # cleanup | function run_clean { | ||||||
| latexmk -C |     latexmk -C | ||||||
| if [ -f chapter/out.tex ] |  | ||||||
| then |     if [ -f main.bbl ] | ||||||
|  |     then | ||||||
|  |     rm main.bbl | ||||||
|  |     fi | ||||||
|  |  | ||||||
|  |     if [ -f main.lol ] | ||||||
|  |     then | ||||||
|  |     rm main.lol | ||||||
|  |     fi | ||||||
|  |  | ||||||
|  |     if [ -f main.ptc ] | ||||||
|  |     then | ||||||
|  |     rm main.ptc | ||||||
|  |     fi | ||||||
|  |  | ||||||
|  |     if [ -f main.run.xml ] | ||||||
|  |     then | ||||||
|  |     rm main.run.xml | ||||||
|  |     fi | ||||||
|  |  | ||||||
|  |     if [ -f chapter/out.tex ] | ||||||
|  |     then | ||||||
|         rm chapter/out.md |         rm chapter/out.md | ||||||
|         rm chapter/out.tex |         rm chapter/out.tex | ||||||
| fi |     fi | ||||||
|  |  | ||||||
|  |     shopt -s nullglob | ||||||
|  |     for f in appendix/generated/*.tex | ||||||
|  |     do | ||||||
|  |         rm $f | ||||||
|  |     done | ||||||
|  | } | ||||||
|  |  | ||||||
|  | function run_pandoc { | ||||||
|  |     if [ -f chapter/out.tex ] | ||||||
|  |     then | ||||||
|  |         rm chapter/out.md | ||||||
|  |         rm chapter/out.tex | ||||||
|  |     fi | ||||||
|      |      | ||||||
| # run pandoc |  | ||||||
| if [ $1 == "pandoc" ] |  | ||||||
| then |  | ||||||
|     cat chapter/*.md > chapter/out.md |     cat chapter/*.md > chapter/out.md | ||||||
|     pandoc --lua-filter templates/germanquotes.lua --citeproc --filter pandoc-crossref \ |     pandoc --lua-filter templates/germanquotes.lua --citeproc --filter pandoc-crossref \ | ||||||
|         -M cref=true --top-level-division=chapter \ |         -M cref=true --top-level-division=chapter \ | ||||||
|         --bibliography library/library.bib --biblatex \ |         --bibliography library/library.bib --biblatex \ | ||||||
|         -o chapter/out.tex chapter/out.md |         -o chapter/out.tex chapter/out.md | ||||||
| fi | } | ||||||
|  |  | ||||||
| # run latex build | function run_latexmk { | ||||||
| if [ $1 != "clean" ] |  | ||||||
| then |  | ||||||
|     latexmk -latexoption="-shell-escape" main.tex |     latexmk -latexoption="-shell-escape" main.tex | ||||||
| fi | } | ||||||
|  |  | ||||||
|  | function run_pandoc_appendix { | ||||||
|  |     shopt -s nullglob | ||||||
|  |      | ||||||
|  |     for f in appendix/generated/*.tex | ||||||
|  |     do | ||||||
|  |         rm $f | ||||||
|  |     done | ||||||
|  |  | ||||||
|  |     for f in appendix/*.md | ||||||
|  |     do | ||||||
|  |         filename=$(basename -- "$f") | ||||||
|  |         filename="${filename%.*}" | ||||||
|  |         pandoc --lua-filter templates/germanquotes.lua --citeproc --filter pandoc-crossref \ | ||||||
|  |         -M cref=true --top-level-division=chapter \ | ||||||
|  |         --bibliography library/library.bib --biblatex \ | ||||||
|  |         -o appendix/generated/$filename.tex appendix/$filename.md | ||||||
|  |     done | ||||||
|  | } | ||||||
|  |  | ||||||
|  | case $1 in | ||||||
|  |     "clean") | ||||||
|  |         run_clean | ||||||
|  |         ;; | ||||||
|  |     "pandoc") | ||||||
|  |         run_pandoc | ||||||
|  |         run_pandoc_appendix | ||||||
|  |         run_latexmk | ||||||
|  |         ;; | ||||||
|  |     "latex") | ||||||
|  |         run_latexmk | ||||||
|  |         ;; | ||||||
|  |     "appendix") | ||||||
|  |         run_pandoc_appendix | ||||||
|  |         ;; | ||||||
|  |     *) | ||||||
|  |         echo $"Usage: $0 {clean|pandoc|latex}" | ||||||
|  |         exit 1 | ||||||
|  | esac | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user