run: cargo install --path helpers/mdbook-exercise-linker
- name: Install link shortener plugin
run: cargo install --path helpers/mdbook-link-shortener
- - name: Install mdbook-pandoc and related dependencies
+ - name: Install mdbook-pandoc, calibre and related dependencies
run: |
cargo install mdbook-pandoc --locked --version 0.7.1
sudo apt-get update
- sudo apt-get install -y fonts-noto
+ sudo apt-get install -y fonts-noto calibre
export PANDOC_VERSION=3.3
curl -LsSf https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-linux-amd64.tar.gz | tar zxf -
run: |
cd book
mdbook build
+ - name: Convert HTML to ePUB
+ run: |
+ cd book/book/pandoc/html
+ sed -i 's|<code>\\newpage</code>{=latex}||g' 100-exercises-to-learn-rust.html
+ ebook-convert 100-exercises-to-learn-rust.html 100-exercises-to-learn-rust.epub \
+ --embed-all-fonts \
+ --subset-embedded-fonts
- name: Link Checker
uses: lycheeverse/lychee-action@v1
with:
with:
name: paperback
path: book/book/pandoc/paperback/100-exercises-to-learn-rust.pdf
+ - uses: actions/upload-artifact@v4
+ with:
+ name: ePUB
+ path: book/book/pandoc/html/100-exercises-to-learn-rust.epub
is_fresh:
runs-on: ubuntu-latest
src = "src"
title = "100 Exercises To Learn Rust"
+[preprocessor.exercise-linker]
+exercise_root_url = "https://github.com/mainmatter/100-exercises-to-learn-rust/tree/main/exercises"
+
+[preprocessor.link-shortener]
+base_url = "https://ruex.io"
+renderers = ["pandoc"]
+mapping = "link2alias.json"
+verify = false
+after = ["exercise-linker"]
+
+[output.html]
+git-repository-url = "https://github.com/mainmatter/100-exercises-to-learn-rust"
+
[output.pandoc]
optional = true
hosted-html = "https://rust-exercises.com/100-exercises/"
# We use `lualatext` because, right now, it's the only engine
# that supports fallback fonts, which we need for emojis.
pdf-engine = "lualatex"
+metadata-file = "metadata.yml"
[output.pandoc.profile.pdf.variables]
-subtitle = "A hands-on course by Mainmatter"
# You can get these fonts here: https://fonts.google.com/selection?query=noto+color+
mainfont = "Noto Serif"
sansfont = "Noto Sans"
output-file = "100-exercises-to-learn-rust.pdf"
to = "latex"
highlight-style = "monochrome"
+metadata-file = "metadata.yml"
# We use `lualatext` because, right now, it's the only engine
# that supports fallback fonts, which we need for emojis.
pdf-engine = "lualatex"
[output.pandoc.profile.paperback.variables]
-subtitle = "A hands-on course by Mainmatter"
# You can get these fonts here: https://fonts.google.com/selection?query=noto+color+
mainfont = "Noto Serif"
sansfont = "Noto Sans"
]
links-as-notes = true
-[output.html]
-git-repository-url = "https://github.com/mainmatter/100-exercises-to-learn-rust"
-
-[preprocessor.exercise-linker]
-exercise_root_url = "https://github.com/mainmatter/100-exercises-to-learn-rust/tree/main/exercises"
+# We go through HTML, rather than directly to ePUB, since routing
+# Pandoc's HTML through Calibre's ePUB converter gives us better results.
+[output.pandoc.profile.html]
+output-file = "100-exercises-to-learn-rust.html"
+to = "html"
+highlight-style = "monochrome"
+embed-resources = true
+standalone = true
+metadata-file = "metadata.yml"
-[preprocessor.link-shortener]
-base_url = "https://ruex.io"
-renderers = ["pandoc"]
-mapping = "link2alias.json"
-verify = false
-after = ["exercise-linker"]
+[output.pandoc.profile.html.variables]
+# You can get these fonts here: https://fonts.google.com/selection?query=noto+color+
+mainfont = "Noto Serif"
+sansfont = "Noto Sans"
+monofont = "Noto Sans Mono"
+mainfontfallback = ["Noto Color Emoji:mode=harf"]
+sansfontfallback = ["Noto Color Emoji:mode=harf"]
+monofontfallback = [
+ "Noto Color Emoji:mode=harf",
+]
+linkcolor = "blue"
+urlcolor = "blue"
+urlstyle = "rm"