Skip to content

Add PDFs generation with Table Of Content #114

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

Merged
merged 6 commits into from
May 30, 2024
Merged
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
Binary file modified downloads/typescript-book-zh_CN.epub
Binary file not shown.
Binary file modified downloads/typescript-book-zh_CN.pdf
Binary file not shown.
Binary file modified downloads/typescript-book.epub
Binary file not shown.
Binary file modified downloads/typescript-book.pdf
Binary file not shown.
17 changes: 13 additions & 4 deletions tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ nvm use
npm install
```

```shell
brew install pandoc
brew install epubcheck
brew install --cask calibre
```

## Commands

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

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

## Debug Epub issues
## Debug EPUB Issues

You can download and use the following tools to validate and debug the created EPUB files.
To debug the EPUB files you create, follow these steps:

First, download and install Sigil. You can use the following command to install Sigil:

```shell
brew install epubcheck
brew install --cask sigil
```

For instance, run the EPUB check using:
Next, run an EPUB check to validate your EPUB file. For example:

```shell
epubcheck ../downloads/typescript-book.epub
```

Finally, open the EPUB file using Sigil for detailed inspection.

## How to Contribute to This E-Book

To contribute to this e-book, follow these steps:
Expand Down
14 changes: 9 additions & 5 deletions tools/make-books.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ else
echo "You need to install epubcheck. Please visit: https://www.w3.org/publishing/epubcheck/docs/installation/"
exit 1
fi
if command -v ebook-convert &>/dev/null; then
echo "calibre is installed"
else
echo "You need to install calibre. Please visit: https://calibre-ebook.com/download"
exit 1
fi

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

cd ./tools || exit

# Generate PDFs
npm run make-pdf --source=$INPUT_EN --destination=$OUTPUT_EN
npm run make-pdf --source=$INPUT_CN --destination=$OUTPUT_CN
# Generate PDFs
ebook-convert $DIR_DOWNLOADS/$OUTPUT_EN.epub $DIR_DOWNLOADS/$OUTPUT_EN.pdf --pdf-page-numbers
ebook-convert $DIR_DOWNLOADS/$OUTPUT_CN.epub $DIR_DOWNLOADS/$OUTPUT_CN.pdf --pdf-page-numbers

echo "Books were created. Please commit!"
Loading
Loading