1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-04-02 09:44:11 +02:00

Render book as PDF in publish.yml workflow (#1572)

Renders the book as a PDF and includes it in the published HTML bundle
as `comprehensive-rust.pdf`.

Closes #1543
This commit is contained in:
Max Heller 2024-01-15 17:02:05 -05:00 committed by GitHub
parent 3f1957c56d
commit 9ed01cca77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 43 additions and 1 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/usr/bin/env bash
set -Eeuo pipefail
# Usage: build.sh <book-lang> <dest-dir>
@ -29,9 +29,13 @@ else
export MDBOOK_BOOK__LANGUAGE=$book_lang
export MDBOOK_OUTPUT__HTML__SITE_URL=/comprehensive-rust/$book_lang/
export MDBOOK_OUTPUT__HTML__REDIRECT='{}'
# Include language-specific Pandoc configuration
[ -f "pandoc/$book_lang.yaml" ] && export MDBOOK_OUTPUT__PANDOC__PROFILE__PDF__DEFAULTS="pandoc/$book_lang.yaml"
fi
mdbook build -d "$dest_dir"
[ -f "$dest_dir/pandoc/pdf/comprehensive-rust.pdf" ] && mv "$dest_dir/pandoc/pdf/comprehensive-rust.pdf" "$dest_dir/html/"
(cd "$dest_dir/exerciser" && zip --recurse-paths ../html/comprehensive-rust-exercises.zip comprehensive-rust-exercises/)
echo "::endgroup::"

View File

@ -39,6 +39,13 @@ jobs:
- name: Install mdbook
uses: ./.github/workflows/install-mdbook
- name: Install mdbook-pandoc and related dependencies
run: |
cargo install mdbook-pandoc --locked --version 0.4.0
sudo apt-get install -y texlive texlive-luatex texlive-lang-cjk librsvg2-bin fonts-noto
curl -LsSf https://github.com/jgm/pandoc/releases/download/3.1.11/pandoc-3.1.11-linux-amd64.tar.gz | tar zxf -
echo "$PWD/pandoc-3.1.11/bin" >> $GITHUB_PATH
- name: Build course in English
run: .github/workflows/build.sh en book

View File

@ -29,6 +29,21 @@ verbose = false # Report timing information.
# [preprocessor.aspect-ratio-helper]
# command = "./aspect-ratio-helper.py"
[output.pandoc]
optional = true
[output.pandoc.profile.pdf]
output-file = "comprehensive-rust.pdf"
pdf-engine = "lualatex"
[output.pandoc.profile.pdf.variables]
mainfont = "Noto Serif"
sansfont = "Noto Sans"
monofont = "Noto Sans Mono"
geometry = ["margin=1.25in"]
linkcolor = "blue"
urlcolor = "red"
[output.html]
curly-quotes = true
additional-js = ["theme/speaker-notes.js"]

4
pandoc/ja.yaml Normal file
View File

@ -0,0 +1,4 @@
variables:
CJKmainfont: "Noto Serif CJK JP"
CJKsansfont: "Noto Sans CJK JP"
CJKmonofont: "Noto Sans Mono CJK JP"

4
pandoc/ko.yaml Normal file
View File

@ -0,0 +1,4 @@
variables:
CJKmainfont: "Noto Serif CJK KR"
CJKsansfont: "Noto Sans CJK KR"
CJKmonofont: "Noto Sans Mono CJK KR"

4
pandoc/zh-CN.yaml Normal file
View File

@ -0,0 +1,4 @@
variables:
CJKmainfont: "Noto Serif CJK SC"
CJKsansfont: "Noto Sans CJK SC"
CJKmonofont: "Noto Sans Mono CJK SC"

4
pandoc/zh-TW.yaml Normal file
View File

@ -0,0 +1,4 @@
variables:
CJKmainfont: "Noto Serif CJK TC"
CJKsansfont: "Noto Sans CJK TC"
CJKmonofont: "Noto Sans Mono CJK TC"