2012-08-29 20:31:16 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Generate PDF from composer documentation.
|
|
|
|
# dependencies:
|
|
|
|
# * pandoc
|
|
|
|
# * latex
|
|
|
|
|
|
|
|
for file in $(find . -type f -name '*.md')
|
|
|
|
do
|
|
|
|
pandoc -o $(dirname $file)/$(basename $file .md).tex $file
|
|
|
|
done
|
|
|
|
|
|
|
|
> book.tex
|
|
|
|
cat >> book.tex <<EOF
|
2012-08-31 00:23:18 +00:00
|
|
|
\documentclass[letterpaper]{book}
|
|
|
|
|
2012-08-29 20:31:16 +00:00
|
|
|
\title{Composer}
|
2012-08-31 00:22:26 +00:00
|
|
|
\author{The Composer Community}
|
2012-08-29 20:31:16 +00:00
|
|
|
|
2012-08-31 00:33:20 +00:00
|
|
|
\usepackage[letterpaper,margin=1.5in]{geometry}
|
2012-08-29 20:31:16 +00:00
|
|
|
\usepackage{hyperref}
|
|
|
|
\usepackage{url}
|
|
|
|
\usepackage{enumerate}
|
|
|
|
\usepackage{listings}
|
|
|
|
\usepackage{microtype}
|
|
|
|
\usepackage[htt]{hyphenat}
|
|
|
|
\usepackage[utf8]{inputenc}
|
|
|
|
\usepackage[T1]{fontenc}
|
|
|
|
\usepackage{textcomp}
|
|
|
|
\usepackage{tgpagella}
|
|
|
|
|
|
|
|
\lstset{
|
|
|
|
breaklines=true,
|
|
|
|
basicstyle=\ttfamily
|
|
|
|
}
|
|
|
|
|
|
|
|
\begin{document}
|
|
|
|
|
|
|
|
\setlength{\parindent}{0cm}
|
|
|
|
\setlength{\parskip}{0.1cm}
|
|
|
|
|
|
|
|
\maketitle
|
|
|
|
\tableofcontents
|
|
|
|
|
|
|
|
\setlength{\parskip}{0.4cm}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat *.tex >> book.tex
|
|
|
|
|
|
|
|
# apply only to main part of book
|
|
|
|
sed -i.bak 's/\\section{/\\chapter{/g' book.tex
|
|
|
|
sed -i.bak 's/\\subsection{/\\section{/g' book.tex
|
|
|
|
sed -i.bak 's/\\subsubsection{/\\subsection{/g' book.tex
|
|
|
|
sed -i.bak '/←/d' book.tex
|
|
|
|
sed -i.bak '/→/d' book.tex
|
|
|
|
sed -i.bak 's/\\chapter{composer.json}/\\chapter[Schema]{composer.json}/g' book.tex
|
|
|
|
|
|
|
|
echo "\chapter{Articles}" >> book.tex
|
|
|
|
cat articles/*.tex >> book.tex
|
|
|
|
echo "\chapter{FAQs}" >> book.tex
|
|
|
|
cat faqs/*.tex >> book.tex
|
|
|
|
echo >> book.tex
|
|
|
|
echo "\end{document}" >> book.tex
|
|
|
|
|
|
|
|
# apply to whole book
|
|
|
|
sed -i.bak 's/\\begin{verbatim}/\\vspace{1em} \\begin{lstlisting}/g' book.tex
|
|
|
|
sed -i.bak 's/\\end{verbatim}/\\end{lstlisting}/g' book.tex
|
|
|
|
rm book.tex.bak
|
|
|
|
|
|
|
|
pdflatex book.tex
|
|
|
|
pdflatex book.tex
|
|
|
|
|
|
|
|
rm *.tex articles/*.tex dev/*.tex faqs/*.tex
|
|
|
|
rm book.{aux,log,out,toc}
|