mirror of
https://github.com/mainmatter/100-exercises-to-learn-rust
synced 2024-12-25 21:58:26 +01:00
Add ePUB format (#130)
This commit is contained in:
parent
f9a1d427b2
commit
fb8f83a518
3 changed files with 54 additions and 15 deletions
15
.github/workflows/ci.yml
vendored
15
.github/workflows/ci.yml
vendored
|
@ -20,11 +20,11 @@ jobs:
|
|||
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 -
|
||||
|
@ -70,6 +70,13 @@ jobs:
|
|||
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:
|
||||
|
@ -94,6 +101,10 @@ jobs:
|
|||
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
|
||||
|
|
|
@ -5,6 +5,19 @@ multilingual = false
|
|||
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/"
|
||||
|
@ -16,9 +29,9 @@ highlight-style = "tango"
|
|||
# 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"
|
||||
|
@ -43,12 +56,12 @@ header-includes = [
|
|||
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"
|
||||
|
@ -68,15 +81,26 @@ header-includes = [
|
|||
]
|
||||
links-as-notes = true
|
||||
|
||||
[output.html]
|
||||
git-repository-url = "https://github.com/mainmatter/100-exercises-to-learn-rust"
|
||||
# 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.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.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"
|
||||
|
|
4
book/metadata.yml
Normal file
4
book/metadata.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
title: "100 Exercises To Learn Rust"
|
||||
subtitle: "A hands-on course by Mainmatter"
|
||||
author: "Luca Palmieri"
|
||||
keywords: ["Rust", "Programming"]
|
Loading…
Reference in a new issue