tldr/scripts/generate-pdf.sh

30 lines
660 B
Bash
Raw Normal View History

2016-05-09 14:16:43 +01:00
#!/usr/bin/env sh
src=../pages
target=../tldr-book.pdf
template=template.tex
function getContent {
cd $src
2016-05-09 14:16:43 +01:00
pages=$(ls -d */ | # list directories
tr -d '/' | # remove trailing slash
tr '[:lower:]' '[:upper:]') # transform to uppercase
2016-05-09 14:16:43 +01:00
for page in $pages; do
2016-05-09 14:16:43 +01:00
echo "\n\n# $page" >&1 # add a new chapter
2016-05-09 14:16:43 +01:00
for file in $(ls $page); do
2016-05-09 14:16:43 +01:00
echo "\n\n" | # add some line breaks for latex
cat - $page/$file | # get the content of the tldr file
sed 's/^#/##/g' >&1 # transform h1 (chapter) to h2 (section)
2016-05-09 14:16:43 +01:00
done
done
2016-05-09 14:16:43 +01:00
}
getContent | pandoc -o $target --template $template --latex-engine xelatex --listings