mdbook

TurnToJPG -->


Install via:

sudo pacman -S mdbook
$ yay mdbook-toc

For using cargo tuna mirror site, do following modifications:

$ vim  ~/.cargo/config 
[source.crates-io]
replace-with = 'tuna'

[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"

Install pdf generation and pdf outline:

$ cargo install mdbook-pdf
$ pip install --break-system-packages mdbook-pdf-outline
$ vim ~/.zshrc
...
export PATH=/home/dash/.cargo/bin:/home/dash/.local/bin:$PATH

Now add following definition to your book:

[preprocessor.toc]
command = "mdbook-toc"
renderer = ["html"]

[output.html]

[output.pdf]
## Set for auto-retrying if failed to generate PDF.
# trying-times = 1
## This backend only support latest Chromium based browsers, not Safari and Firefox currently.
## If needed, please specify the full path.
## If you specify the wrong binary, chances are that there will be a timeout error.
# browser-binary-path = ""
## Assign the static hosting site url so that relative links outside the book can be fixed.
#static_site_url = "https://aye10032.gitbook.io/computernetwork/"
## Check Chrome Devtools Protocol Docs for the explanation of the following params:
## https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF
landscape = false
display-header-footer = true
print-background = true
theme = ""
scale = 0.8
paper-width = 8
paper-height = 10
margin-top = 0.5
margin-bottom = 0.5
margin-left = 0.5
margin-right = 0.5
page-ranges = ""
ignore-invalid-page-ranges = false
header-template = "<h3 style='font-size:8px; margin-left: 48%' class='title'></h3>"
footer-template = "<p style='font-size:10px; margin-left: 48%'><span class='pageNumber'></span> / <span class='totalPages'></span></p>"
prefer-css-page-size = true

[output.pdf-outline]
like-wkhtmltopdf = true

Generate book pdf:

$ mdbook pdf
$ ls -l -h book/pdf-outline/*.pdf
-rw-r--r-- 1 dash root 8.8M May 17 10:00 book/pdf-outline/output.pdf