Skip to content

Commit 3a1a351

Browse files
authored
Add PDFs generation with Table Of Content (#114)
* generate pdf with toc * remove md-to-pdf * improve readme * add check for calibre * update books * add page number
1 parent 01f05fb commit 3a1a351

8 files changed

+188
-2603
lines changed

downloads/typescript-book-zh_CN.epub

-1 Bytes
Binary file not shown.

downloads/typescript-book-zh_CN.pdf

-2.72 MB
Binary file not shown.

downloads/typescript-book.epub

1 Byte
Binary file not shown.

downloads/typescript-book.pdf

-2.67 MB
Binary file not shown.

tools/README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ nvm use
1313
npm install
1414
```
1515

16+
```shell
17+
brew install pandoc
18+
brew install epubcheck
19+
brew install --cask calibre
20+
```
21+
1622
## Commands
1723

1824
Use `make` to run the main commands:
@@ -80,21 +86,24 @@ After generating the Epub files, thoroughly test them, and once you're satisfied
8086

8187
These tools will assist you in efficiently working with Markdown books and ensure a smooth and organized process. Happy writing!
8288

83-
## Debug Epub issues
89+
## Debug EPUB Issues
8490

85-
You can download and use the following tools to validate and debug the created EPUB files.
91+
To debug the EPUB files you create, follow these steps:
92+
93+
First, download and install Sigil. You can use the following command to install Sigil:
8694

8795
```shell
88-
brew install epubcheck
8996
brew install --cask sigil
9097
```
9198

92-
For instance, run the EPUB check using:
99+
Next, run an EPUB check to validate your EPUB file. For example:
93100

94101
```shell
95102
epubcheck ../downloads/typescript-book.epub
96103
```
97104

105+
Finally, open the EPUB file using Sigil for detailed inspection.
106+
98107
## How to Contribute to This E-Book
99108

100109
To contribute to this e-book, follow these steps:

tools/make-books.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ else
2828
echo "You need to install epubcheck. Please visit: https://www.w3.org/publishing/epubcheck/docs/installation/"
2929
exit 1
3030
fi
31+
if command -v ebook-convert &>/dev/null; then
32+
echo "calibre is installed"
33+
else
34+
echo "You need to install calibre. Please visit: https://calibre-ebook.com/download"
35+
exit 1
36+
fi
3137

3238
# Generate eBooks
3339
pandoc -o $DIR_DOWNLOADS/$OUTPUT_EN.epub --metadata title="$TITLE_EN" --metadata author="$AUTHOR" -s $INPUT_EN.md
@@ -37,10 +43,8 @@ pandoc -o $DIR_DOWNLOADS/$OUTPUT_CN.epub --metadata title="$TITLE_CN" --metadata
3743
epubcheck $DIR_DOWNLOADS/$OUTPUT_CN.epub
3844
epubcheck $DIR_DOWNLOADS/$OUTPUT_CN.epub
3945

40-
cd ./tools || exit
41-
42-
# Generate PDFs
43-
npm run make-pdf --source=$INPUT_EN --destination=$OUTPUT_EN
44-
npm run make-pdf --source=$INPUT_CN --destination=$OUTPUT_CN
46+
# Generate PDFs
47+
ebook-convert $DIR_DOWNLOADS/$OUTPUT_EN.epub $DIR_DOWNLOADS/$OUTPUT_EN.pdf --pdf-page-numbers
48+
ebook-convert $DIR_DOWNLOADS/$OUTPUT_CN.epub $DIR_DOWNLOADS/$OUTPUT_CN.pdf --pdf-page-numbers
4549

4650
echo "Books were created. Please commit!"

0 commit comments

Comments
 (0)