make-pdf.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. \raggedbottom
  31. \begin{document}
  32. \setlength{\parindent}{0cm}
  33. \setlength{\parskip}{0.1cm}
  34. \maketitle
  35. \tableofcontents
  36. \setlength{\parskip}{0.4cm}
  37. EOF
  38. cat *.tex >> book.tex
  39. # apply only to main part of book
  40. sed -i.bak 's/\\section{/\\chapter{/g' book.tex
  41. sed -i.bak 's/\\subsection{/\\section{/g' book.tex
  42. sed -i.bak 's/\\subsubsection{/\\subsection{/g' book.tex
  43. sed -i.bak '/←/d' book.tex
  44. sed -i.bak '/→/d' book.tex
  45. sed -i.bak 's/\\chapter{composer.json}/\\chapter[Schema]{composer.json}/g' book.tex
  46. echo "\chapter{Articles}" >> book.tex
  47. cat articles/*.tex >> book.tex
  48. echo "\chapter{FAQs}" >> book.tex
  49. cat faqs/*.tex >> book.tex
  50. echo >> book.tex
  51. echo "\end{document}" >> book.tex
  52. # apply to whole book
  53. sed -i.bak 's/\\begin{verbatim}/\\begin{minipage}{\\textwidth} \\begin{lstlisting}/g' book.tex
  54. sed -i.bak 's/\\end{verbatim}/\\end{lstlisting} \\end{minipage}/g' book.tex
  55. rm book.tex.bak
  56. pdflatex book.tex
  57. pdflatex book.tex
  58. rm *.tex articles/*.tex dev/*.tex faqs/*.tex
  59. rm book.{aux,log,out,toc}