Skip to content

Commit

Permalink
feat: render PDF version of book with mdbook-pandoc (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
max-heller authored Mar 16, 2024
1 parent a4d5ab5 commit 2ccd0e1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .github/workflows/install-mdbook/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,12 @@ runs:
- name: Install i18n-helpers
run: cargo install mdbook-i18n-helpers --locked --version '${{ steps.mdbook-i18n-helpers-version.outputs.version }}'
shell: bash

- name: Install mdbook-pandoc and related dependencies
run: |
cargo install mdbook-pandoc --locked --version 0.5.0
sudo apt-get update
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.12.2/pandoc-3.1.12.2-linux-amd64.tar.gz | tar zxf -
echo "$PWD/pandoc-3.1.12.2/bin" >> $GITHUB_PATH
shell: bash
5 changes: 4 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ jobs:
uses: ./.github/workflows/install-mdbook

- name: Build course in English
run: mdbook build -d book
run: |
mdbook build -d book
mv book/html/* book/pandoc/pdf/patterns.pdf book/
rm -r book/html book/pandoc
# TODO: Activate when first translation is available
# - name: Build all translations
Expand Down
17 changes: 17 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,20 @@ editable = false
# Redirects in the form of "old-path" = "new-path", where the new path
# is relative to the old path.
"functional/lenses.html" = "optics.html"

[output.pandoc]
optional = true
hosted-html = "https://rust-unofficial.github.io/patterns/"

[output.pandoc.profile.pdf]
output-file = "patterns.pdf"
pdf-engine = "lualatex"

[output.pandoc.profile.pdf.variables]
mainfont = "Noto Serif"
sansfont = "Noto Sans"
monofont = "Noto Sans Mono"
mainfontfallback = ["NotoSerifCJKSC:"]
geometry = ["margin=1.25in"]
linkcolor = "blue"
urlcolor = "red"

0 comments on commit 2ccd0e1

Please sign in to comment.