Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAI: update script make-pdf #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions list_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""List Markdown files included in `toc.md`."""
import re


TOC_FILE_NAME = 'toc.md'


def list_md_files():
with open(TOC_FILE_NAME, 'r') as f:
md = f.readlines()
files = set()
for line in md:
if not line.startswith(' *'):
continue
s = line.split('(')[1].split(')')[0].split('#')[0]
assert s.startswith('/'), s
s = s[1:]
if s in files:
continue
if s.startswith('libslic3r-doc'):
continue
files.add(s)
print(s)


if __name__ == '__main__':
list_md_files()
12 changes: 6 additions & 6 deletions make-pdf
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# apt-get install pandoc
# apt-get install texlive-xetex
# apt-get install imagemagick
# apt-get install pdftk-java

echo create tmp directory with sources: src.pdf
rm -rf src.pdf
Expand All @@ -16,22 +16,22 @@ mkdir tmp
echo create tmp direcetory for images
for DIR in $(find ../src -type d -name images); do cp -R $DIR .; done

echo create create book.pdf
echo create book.pdf

FILES=""

for FILE in $(grep "^ *" toc.md | cut -d/ -f2- | tr ')' '#' | cut -d'#' -f1 | uniq)
for FILE in $(python ../list_files.py)
do
SRC=${FILE}.md
DST=$(basename $SRC .md).pdf

printf "create %-32s from %s\n" ${DST} ${SRC}.md
pandoc ${SRC} -o tmp/${DST}
printf "create %-32s from %s\n" ${DST} ${SRC}
pandoc ${SRC} --latex-engine=xelatex -o tmp/${DST}

FILES="$FILES tmp/$DST"
done

echo create slic3r-book.pdf
convert -quality 100 -density 300x300 $FILES slic3r-book.pdf
pdftk $FILES cat output slic3r-book.pdf

rm -rf tmp