From fdd8f5e1eeb72ff66243f51bc08120c689a4e1d6 Mon Sep 17 00:00:00 2001 From: yongliang Date: Sat, 1 Jul 2023 21:14:52 +0800 Subject: [PATCH 1/2] Add generate pdf file script --- README.md | 1 + genpdf.sh | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100755 genpdf.sh diff --git a/README.md b/README.md index a61ea92b..64f0a4b1 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ ## 教程简介 - 在线阅读: https://course.rs +- 离线阅读: 参考 genpdf.sh 脚本 **`Rust语言圣经`**涵盖从**入门到精通**所需的 Rust 知识,目录及内容都经过深思熟虑的设计,同时语言生动幽默,行文流畅自如,摆脱技术书籍常有的机器味和晦涩感。 diff --git a/genpdf.sh b/genpdf.sh new file mode 100755 index 00000000..ebf82862 --- /dev/null +++ b/genpdf.sh @@ -0,0 +1,34 @@ +#! /bin/sh + +########################################################### +# Description: +# This script write for mdbook project to generate pdf +########################################################### + +cargo install mdbook mdbook-pdf +hasPdfSec=$(grep "output.pdf" ./book.toml) + +if [ "$hasPdfSec" = "" ]; then + echo "===>>> Backup book.toml file..." + cp book.toml book.toml.bak + cat >> book.toml << EOF + +[output.pdf] +scale = 1 +paper-width = 10 +paper-height = 12 +margin-top = 1 +margin-bottom = 1 +margin-left = 1 +EOF +fi +echo "===>>> Start build pdf..." +mdbook build +today=$(date +%Y%m%d) +echo "===>>> PDF rename to rust-curse-$today.pdf" +mv book/pdf/output.pdf rust-curse-"$today".pdf +if [ -f book.toml.bak ]; then + echo "===>>> Reverse book.toml file..." + mv book.toml.bak book.toml +fi +exit 0 \ No newline at end of file From 8daa8db49a638755a01a99b7944daea2dfe14da0 Mon Sep 17 00:00:00 2001 From: Sunface Date: Thu, 6 Jul 2023 09:47:13 +0800 Subject: [PATCH 2/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 64f0a4b1..3f9a8470 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ ## 教程简介 - 在线阅读: https://course.rs -- 离线阅读: 参考 genpdf.sh 脚本 +- 离线阅读: course.pdf **`Rust语言圣经`**涵盖从**入门到精通**所需的 Rust 知识,目录及内容都经过深思熟虑的设计,同时语言生动幽默,行文流畅自如,摆脱技术书籍常有的机器味和晦涩感。