Skip to content

Commit 01f05fb

Browse files
authored
Create PDF books from Markdown files (#113)
1 parent e5cfd0d commit 01f05fb

8 files changed

+2617
-162
lines changed

downloads/typescript-book-zh_CN.epub

1 Byte
Binary file not shown.

downloads/typescript-book-zh_CN.pdf

3.85 MB
Binary file not shown.

downloads/typescript-book.epub

4 Bytes
Binary file not shown.

downloads/typescript-book.pdf

3.35 MB
Binary file not shown.

tools/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Use `make` to run the main commands:
2020
* `make format`: Format Markdown files for books.
2121
* `make check`: Run several checks to ensure the Markdown files are valid.
2222
* `make website`: Create different Markdown pages for the website.
23-
* `make website-preview`: Build and preview website.
23+
* `make website-preview`: Build and preview website locally.
2424
* `make website-deploy`: Build and deploy website to GitHub Pages.
2525
* `make books`: Create .epub books.
2626

@@ -94,3 +94,13 @@ For instance, run the EPUB check using:
9494
```shell
9595
epubcheck ../downloads/typescript-book.epub
9696
```
97+
98+
## How to Contribute to This E-Book
99+
100+
To contribute to this e-book, follow these steps:
101+
102+
* Update the main Markdown file with your changes.
103+
* Run `make check` to ensure the linter and other checks pass.
104+
* Preview the website locally with `make website-preview` to make sure it works as expected.
105+
* Generate the e-books by running `make books`.
106+
* Submit your PR and share your awesome contributions!

tools/make-books.sh

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
#!/bin/bash
2-
echo "Making ebooks ..."
3-
DIR_DOWNLOADS=downloads
2+
DIR_DOWNLOADS="downloads"
3+
4+
INPUT_EN="README"
5+
INPUT_CN="README-zh_CN"
6+
7+
OUTPUT_EN="typescript-book"
8+
OUTPUT_CN="typescript-book-zh_CN"
9+
10+
AUTHOR="Simone Poggiali"
11+
TITLE_EN="The Concise TypeScript Book"
12+
TITLE_CN="# 简洁的TypeScript之书"
413

514
cd ../
615

16+
echo "Making ebooks ..."
17+
718
# Check dependencies
819
if command -v pandoc &>/dev/null; then
920
echo "pandoc is installed"
@@ -19,11 +30,17 @@ else
1930
fi
2031

2132
# Generate eBooks
22-
pandoc -o $DIR_DOWNLOADS/typescript-book.epub --metadata title="The Concise TypeScript Book" --metadata author="Simone Poggiali" -s README.md
23-
pandoc -o $DIR_DOWNLOADS/typescript-book-zh_CN.epub --metadata title="# 简洁的TypeScript之书" --metadata author="Simone Poggiali" -s README-zh_CN.md
33+
pandoc -o $DIR_DOWNLOADS/$OUTPUT_EN.epub --metadata title="$TITLE_EN" --metadata author="$AUTHOR" -s $INPUT_EN.md
34+
pandoc -o $DIR_DOWNLOADS/$OUTPUT_CN.epub --metadata title="$TITLE_CN" --metadata author="$AUTHOR" -s $INPUT_CN.md
2435

2536
# Validate eBooks
26-
epubcheck $DIR_DOWNLOADS/typescript-book.epub
27-
epubcheck $DIR_DOWNLOADS/typescript-book-zh_CN.epub
37+
epubcheck $DIR_DOWNLOADS/$OUTPUT_CN.epub
38+
epubcheck $DIR_DOWNLOADS/$OUTPUT_CN.epub
39+
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
2845

2946
echo "Books were created. Please commit!"

0 commit comments

Comments
 (0)