In this blog post, I will show you the process of combining and converting a list of markdown files into kindle supported ebook (.mobi) format.
In this example I would be converting official documentation of Docker website into an ebook for offline use.
I will use Pandoc to combine and convert the markdown (.md) files into .epub format. Then I will use Calibre to convert it to .mobi format.
You can follow the steps and modify the linux commands according to your needs.
If you don't have a linux machine, you can use Deepnote platform to run linux commands in jupyter notebook.
Note: If you're running this in Deepnote, you need to append "!" as prefix to each command, so that deepnote can identify it as bash command. If running in linux machine, remove "!" from all commands written below.
Here is a small video tutorial of the working script.
Video Link: https://www.youtube.com/watch?v=L4hGDPLMPcw
Steps to be followed:
# Download Pandoc executable !wget https://github.com/jgm/pandoc/releases/download/220.127.116.11/pandoc-18.104.22.168-1-amd64.deb
# Install pandoc !sudo dpkg -i pandoc-22.214.171.124-1-amd64.deb
# Clone Docker CLI documentation github repository !git clone https://github.com/docker/cli.git
# Verify the list of markdown files and contents of files !cd cli/docs/reference/commandline && ls -la
# Generate ebook from markdown files, *.md picks up all the files with .md as extension !cd cli/docs/reference/commandline && pandoc -o docker_cli.epub --metadata title="Docker CLI Docs" *.md
# Move generated file to required location !mv cli/docs/reference/commandline/docker_cli.epub ~/work/docker_cli.epub
# Install required dependencies for Calibre !apt update -y !apt install libgl1-mesa-glx -y
# Download and install calibre command line utility !wget -q -O- https://download.calibre-ebook.com/linux-installer.sh | sudo sh /dev/stdin
# Convert ebook to kindle supported .mobi format !ebook-convert docker_cli.epub docker_cli.mobi
Now you can transfer generated .mobi file to your kindle device.
There is also a browser extension called EpubPress, which can convert any webpage into a kindle book in a single click. You can use it convert any webpage or blogs to read on Kindle.
You can follow the discussion thread on Hackernews
Originally published at https://themythicalengineer.com on Apr 21, 2021.