Skip to content

Commit c9ed60d

Browse files
Add print-ready PDF (mainmatter#127)
1 parent 0910f39 commit c9ed60d

File tree

11 files changed

+860
-7
lines changed

11 files changed

+860
-7
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ jobs:
1616
with:
1717
fetch-depth: 0
1818
- uses: actions-rust-lang/setup-rust-toolchain@v1
19-
- name: Install plugin
19+
- name: Install exercise plugin
2020
run: cargo install --path helpers/mdbook-exercise-linker
21+
- name: Install link shortener plugin
22+
run: cargo install --path helpers/mdbook-link-shortener
2123
- name: Install mdbook-pandoc and related dependencies
2224
run: |
2325
cargo install mdbook-pandoc --locked --version 0.7.1
@@ -63,6 +65,8 @@ jobs:
6365
with:
6466
tool: mdbook
6567
- name: Build book
68+
env:
69+
LINK_SHORTENER_VERIFY: "true"
6670
run: |
6771
cd book
6872
mdbook build
@@ -82,11 +86,25 @@ jobs:
8286
# When you support multiple formats, the output directory changes
8387
# to include the format in its path.
8488
path: book/book/html
85-
# Upload the PDF book as an artifact
8689
- uses: actions/upload-artifact@v4
8790
with:
88-
name: paperback
91+
name: online-pdf
8992
path: book/book/pandoc/pdf/100-exercises-to-learn-rust.pdf
93+
- uses: actions/upload-artifact@v4
94+
with:
95+
name: paperback
96+
path: book/book/pandoc/paperback/100-exercises-to-learn-rust.pdf
97+
98+
is_fresh:
99+
runs-on: ubuntu-latest
100+
steps:
101+
- uses: actions/checkout@v3
102+
- run: sudo apt-get update && sudo apt-get install -y jq
103+
- run: |
104+
./helpers/json2redirects.sh book/link2alias.json > site/redirects
105+
# Verify nothing has changed, meaning that the redirect file is up-to-date
106+
- run: |
107+
git diff --exit-code site/redirects
90108
91109
formatter:
92110
runs-on: ubuntu-latest

Cargo.lock

Lines changed: 103 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
[workspace]
2-
members = ["exercises/*/*", "helpers/common", "helpers/mdbook-exercise-linker", "helpers/ticket_fields"]
2+
members = [
3+
"exercises/*/*",
4+
"helpers/common",
5+
"helpers/mdbook-exercise-linker",
6+
"helpers/mdbook-link-shortener",
7+
"helpers/ticket_fields",
8+
]
39
resolver = "2"
410

511
# This is needed to guarantee the expected behaviour on that specific exercise,

book/book.toml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,44 @@ header-includes = [
3939
"\\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\\\\{\\},fontsize=\\small}",
4040
]
4141

42+
[output.pandoc.profile.paperback]
43+
output-file = "100-exercises-to-learn-rust.pdf"
44+
to = "latex"
45+
highlight-style = "monochrome"
46+
# We use `lualatext` because, right now, it's the only engine
47+
# that supports fallback fonts, which we need for emojis.
48+
pdf-engine = "lualatex"
49+
50+
[output.pandoc.profile.paperback.variables]
51+
subtitle = "A hands-on course by Mainmatter"
52+
# You can get these fonts here: https://fonts.google.com/selection?query=noto+color+
53+
mainfont = "Noto Serif"
54+
sansfont = "Noto Sans"
55+
monofont = "Noto Sans Mono"
56+
mainfontfallback = ["Noto Color Emoji:mode=harf"]
57+
sansfontfallback = ["Noto Color Emoji:mode=harf"]
58+
monofontfallback = [
59+
"Noto Color Emoji:mode=harf",
60+
]
61+
urlstyle = "rm"
62+
documentclass = "book"
63+
fontsize = "11pt"
64+
geometry = "papersize={8in,10in},top=2cm,bottom=2cm,left=2.4cm,right=2.4cm"
65+
header-includes = [
66+
# Reduce font size of code blocks
67+
"\\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\\\\{\\},fontsize=\\small}",
68+
]
69+
links-as-notes = true
70+
4271
[output.html]
4372
git-repository-url = "https://github.com/mainmatter/100-exercises-to-learn-rust"
4473

4574
[preprocessor.exercise-linker]
4675
exercise_root_url = "https://github.com/mainmatter/100-exercises-to-learn-rust/tree/main/exercises"
76+
77+
[preprocessor.link-shortener]
78+
base_url = "https://ruex.io"
79+
renderers = ["pandoc"]
80+
mapping = "link2alias.json"
81+
verify = false
82+
after = ["exercise-linker"]

0 commit comments

Comments
 (0)