From e1c58bba971725b19a56695bd9b27c356050e2d3 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Sat, 5 Aug 2023 14:38:08 +0200 Subject: [PATCH] feat: add script to generate epub --- scripts/create-book.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 scripts/create-book.sh diff --git a/scripts/create-book.sh b/scripts/create-book.sh new file mode 100755 index 00000000..21ec08af --- /dev/null +++ b/scripts/create-book.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# create working dir +rm -r book/ +mkdir book/ + +# copy data to working dir +cat ../blog/content/edition-2/posts/*/index.md > book/book.md +find ../blog/content/edition-2/posts ! -name "*.md" -exec cp -t book/ {} + + +# remove zola metadata +sed -i '/^+++/,/^+++/d' book/book.md +# remove br in table in 06, pandoc handles the layout +sed -i '/
/d' book/book.md +# details/summary breaks epub layout +sed -i '/^
/d' book/book.md +sed -i '/^<\/details>/d' book/book.md +sed -i '/^/d' book/book.md + +# special fix for linking to different folder +sed -i 's|../paging-introduction/||g' book/book.md + +# go to work dir and create epub +cd book/ +pandoc book.md -o book.epub --metadata title="Writing an OS in Rust" --metadata author="Philipp Oppermann"