make-pdf.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/bash
  2. # Generate PDF from composer documentation.
  3. # dependencies:
  4. # * pandoc
  5. # * latex
  6. for file in $(find . -type f -name '*.md')
  7. do
  8. pandoc -o $(dirname $file)/$(basename $file .md).tex $file
  9. done
  10. > book.tex
  11. cat >> book.tex <<EOF
  12. \documentclass[letterpaper]{book}
  13. \title{Composer}
  14. \author{The Composer Community}
  15. \usepackage[letterpaper,margin=1.5in]{geometry}
  16. \usepackage{hyperref}
  17. \usepackage{url}
  18. \usepackage{enumerate}
  19. \usepackage{listings}
  20. \usepackage{microtype}
  21. \usepackage[htt]{hyphenat}
  22. \usepackage[utf8]{inputenc}
  23. \usepackage[T1]{fontenc}
  24. \usepackage{textcomp}
  25. \usepackage{tgpagella}
  26. \lstset{
  27. breaklines=true,
  28. basicstyle=\ttfamily
  29. }
  30. \begin{document}
  31. \setlength{\parindent}{0cm}
  32. \setlength{\parskip}{0.1cm}
  33. \maketitle
  34. \tableofcontents
  35. \setlength{\parskip}{0.4cm}
  36. EOF
  37. cat *.tex >> book.tex
  38. # apply only to main part of book
  39. sed -i.bak 's/\\section{/\\chapter{/g' book.tex
  40. sed -i.bak 's/\\subsection{/\\section{/g' book.tex
  41. sed -i.bak 's/\\subsubsection{/\\subsection{/g' book.tex
  42. sed -i.bak '/←/d' book.tex
  43. sed -i.bak '/→/d' book.tex
  44. sed -i.bak 's/\\chapter{composer.json}/\\chapter[Schema]{composer.json}/g' book.tex
  45. echo "\chapter{Articles}" >> book.tex
  46. cat articles/*.tex >> book.tex
  47. echo "\chapter{FAQs}" >> book.tex
  48. cat faqs/*.tex >> book.tex
  49. echo >> book.tex
  50. echo "\end{document}" >> book.tex
  51. # apply to whole book
  52. sed -i.bak 's/\\begin{verbatim}/\\begin{minipage}{\\textwidth} \\begin{lstlisting}/g' book.tex
  53. sed -i.bak 's/\\end{verbatim}/\\end{lstlisting} \\end{minipage}/g' book.tex
  54. rm book.tex.bak
  55. pdflatex book.tex
  56. pdflatex book.tex
  57. rm *.tex articles/*.tex dev/*.tex faqs/*.tex
  58. rm book.{aux,log,out,toc}