Converting Markdown to Epub or Mobi

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 u…


This content originally appeared on DEV Community and was authored by Sumit Kumar Singh

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.

workflow

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/2.11.3.2/pandoc-2.11.3.2-1-amd64.deb
# Install pandoc
!sudo dpkg -i pandoc-2.11.3.2-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.


This content originally appeared on DEV Community and was authored by Sumit Kumar Singh


Print Share Comment Cite Upload Translate Updates
APA

Sumit Kumar Singh | Sciencx (2021-04-26T03:09:55+00:00) Converting Markdown to Epub or Mobi. Retrieved from https://www.scien.cx/2021/04/26/converting-markdown-to-epub-or-mobi/

MLA
" » Converting Markdown to Epub or Mobi." Sumit Kumar Singh | Sciencx - Monday April 26, 2021, https://www.scien.cx/2021/04/26/converting-markdown-to-epub-or-mobi/
HARVARD
Sumit Kumar Singh | Sciencx Monday April 26, 2021 » Converting Markdown to Epub or Mobi., viewed ,<https://www.scien.cx/2021/04/26/converting-markdown-to-epub-or-mobi/>
VANCOUVER
Sumit Kumar Singh | Sciencx - » Converting Markdown to Epub or Mobi. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/04/26/converting-markdown-to-epub-or-mobi/
CHICAGO
" » Converting Markdown to Epub or Mobi." Sumit Kumar Singh | Sciencx - Accessed . https://www.scien.cx/2021/04/26/converting-markdown-to-epub-or-mobi/
IEEE
" » Converting Markdown to Epub or Mobi." Sumit Kumar Singh | Sciencx [Online]. Available: https://www.scien.cx/2021/04/26/converting-markdown-to-epub-or-mobi/. [Accessed: ]
rf:citation
» Converting Markdown to Epub or Mobi | Sumit Kumar Singh | Sciencx | https://www.scien.cx/2021/04/26/converting-markdown-to-epub-or-mobi/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.