-
-
Save poa00/8bcd914e1b23e49f4e0407fb432971be to your computer and use it in GitHub Desktop.
Build Gitbook PDF using Pandoc
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
# #!/bin/bash | |
GITBOOK_REP=$1 | |
SUMMARY_FILE="SUMMARY.md" | |
echo $OUTPUT_FILE | |
if [ -d "$GITBOOK_REP" ]; then | |
echo "Entering directory '$GITBOOK_REP'..." | |
cd $GITBOOK_REP | |
if [ -f "$SUMMARY_FILE" ]; then | |
# read summary and get texts by order in a single big file | |
pandoc $SUMMARY_FILE -t html | \ | |
grep -o '<a href=['"'"'"][^"'"'"']*['"'"'"]' | \ | |
sed -e 's/^<a href=["'"'"']//' -e 's/["'"'"']$//'| \ | |
xargs cat | \ | |
pandoc -f markdown --variable fontsize=10pt \ | |
--variable=geometry:b5paper \ | |
--variable mainfont="Arial" \ | |
--variable documentclass=scrbook --toc --latex-engine=xelatex -o book.pdf | |
else | |
echo "File '$SUMMARY_FILE' does not exist" | |
fi | |
else | |
echo "Directory '$GITBOOK_REP' does not exist" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment