Created
November 16, 2020 15:23
-
-
Save kernoeb/c8f3306c898a0f67138018b4beddbbe8 to your computer and use it in GitHub Desktop.
Build a PDF file from Docsify structure (markdown)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install deps | |
# sudo apt-get install -y texlive-latex-base texlive-fonts-recommended texlive-fonts-extra texlive-latex-extra | |
# sudo apt-get install -y texlive-xetex | |
# sudo apt install -y ghostscript | |
# wget https://github.com/jgm/pandoc/releases/download/2.9.2.1/pandoc-2.9.2.1-1-amd64.deb | |
# sudo apt install -y ./pandoc-2.9.2.1-1-amd64.deb | |
# rm ./pandoc-2.9.2.1-1-amd64.deb | |
#cp fonts/*.ttf ~/.fonts # I use Google Fonts (Roboto -> please see line 8) | |
cd book # directory where markdown files can be found | |
alldirs=$(find . -type d | paste -sd:) # get all directories | |
#echo $alldirs | |
tmp=$(grep -oP '(?<=]\().*(?=\))' _sidebar.md | tr '\r\n' ' ') # get all markdown files in order | |
#echo $tmp | |
echo "Creating pdf..." | |
pandoc $tmp -o README.pdf "-fmarkdown-implicit_figures -o" --from=markdown -V geometry:margin=.6in --toc --toc-depth=1 --resource-path $alldirs --variable urlcolor=cyan --pdf-engine=xelatex --wrap=preserve -V documentclass=report -V 'mainfont:Roboto-Regular' -V 'mainfontoptions:BoldFont=Roboto-Bold, ItalicFont=Roboto-Italic, BoldItalicFont=Roboto-BoldItalic' --pdf-engine=xelatex | |
echo "Merging cover" | |
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile="Documentation.pdf" ../cover.pdf README.pdf # to add a cover (merge) | |
rm README.pdf | |
echo "Finish." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
2022 update : https://github.com/kernoeb/docker-docsify-pdf