From 6e910bfe67cdda02e26f0572f167681878067ca5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20El=20Kharroubi?=
 <michael.el-kharroubi@hesge.ch>
Date: Thu, 15 Feb 2024 20:28:18 +0100
Subject: [PATCH] Add module to build book pdf.

---
 .gitlab-ci.yml |  7 ++++++-
 README.md      | 10 ++++++++++
 book/book.toml |  5 +++++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f5e7884..f020b41 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -12,7 +12,12 @@ before_script:
   - curl -sSL https://github.com/ferrous-systems/mdslides/releases/download/v0.3.0/mdslides-v0.3.0-x86_64-unknown-linux-gnu.tar.xz | tar -xJ "mdslides-v0.3.0-x86_64-unknown-linux-gnu/mdslides" && mv mdslides-v0.3.0-x86_64-unknown-linux-gnu/mdslides $HOME/.cargo/bin/ && rm -r mdslides-v0.3.0-x86_64-unknown-linux-gnu
   - rustup component add rustfmt
   - rustup component add clippy
-  - export PATH=$PATH:$HOME/.cargo/bin
+  - curl -L https://github.com/HollowMan6/mdbook-pdf/releases/download/v0.1.8/mdbook-pdf-v0.1.8-x86_64-unknown-linux-gnu -o $HOME/.cargo/bin/mdbook-pdf
+  - chmod +x $HOME/.cargo/bin/mdbook-pdf
+  - mkdir -p $HOME/bin
+  - curl -L https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -o $HOME/bin/chrome.deb
+  - apt-get install -y $HOME/bin/chrome.deb
+  - export PATH=$PATH:$HOME/.cargo/bin:$HOME/bin
   ##
   ## Install ssh-agent if not already installed, it is required by Docker.
   ##
diff --git a/README.md b/README.md
index 735cbec..4c3096d 100644
--- a/README.md
+++ b/README.md
@@ -38,6 +38,7 @@ Pour ce faire il faut installer plusieurs programmes:
 * [mdbook](https://rust-lang.github.io/mdBook/) pour le livre et les slides,
 * [modbook-linkcheck](https://github.com/Michael-F-Bryan/mdbook-linkcheck) pour la vérification des liens su livre,
 * [mdslides](https://github.com/ferrous-systems/mdslides/), uniquement pour les slides.
+* [mdbook-pdf](https://github.com/HollowMan6/mdbook-pdf), pour générer le cours au format pdf.
 
 ### Installation de `mdbook`
 
@@ -80,6 +81,15 @@ $ ./build_slides.sh
 ```
 L'index des slides se trouve ensuite dans `slides/index.html`.
 
+### Installation de `mdbook-pdf`
+
+Pour installer `mdbook-pdf` depuis la dernière version de <https://crates.io/>
+```bash
+cargo install mdbook-pdf
+```
+
+`mdbook-pdf` nécessite un navigateur de type chromium (Google Chrome / Chromium / Microsoft Edge) installé.
+
 ## Inspiration
 
 L'inspiration de ce cours est tirée de trois cours qui ont l'air très bons:
diff --git a/book/book.toml b/book/book.toml
index 767af31..b102e65 100644
--- a/book/book.toml
+++ b/book/book.toml
@@ -11,6 +11,11 @@ mathjax-support = true
 [output.html.playground]
 editable = true
 
+[output.html.print]
+enable = true
+
+[output.pdf]
+
 [output.linkcheck]
 # Should we check links on the internet? Enabling this option adds a
 # non-negligible performance impact
-- 
GitLab