DEV Community

Cover image for How to create an eBook from Markdown using Ibis?
Bobby Iliev
Bobby Iliev

Posted on • Originally published at devdojo.com

How to create an eBook from Markdown using Ibis?

Introduction

A few months ago I wrote two open-source eBooks:

GitHub logo bobbyiliev / introduction-to-bash-scripting

Free Introduction to Bash Scripting eBook

๐Ÿ’ก Introduction to Bash Scripting

This is an open-source introduction to Bash scripting guide/ebook that will help you learn the basics of Bash scripting and start writing awesome Bash scripts that will help you automate your daily SysOps, DevOps, and Dev tasks. No matter if you are a DevOps/SysOps engineer, developer, or just a Linux enthusiast, you can use Bash scripts to combine different Linux commands and automate boring and repetitive daily tasks, so that you can focus on more productive and fun things.

The guide is suitable for anyone working as a developer, system administrator, or a DevOps engineer and wants to learn the basics of Bash scripting.

๐Ÿš€ Download

To download a copy of the ebook use one of the following links:

๐Ÿ“˜ Chapters

The first 13 chapters would be purely focused on getting some solid Bash scripting foundations then the rest ofโ€ฆ

GitHub logo bobbyiliev / introduction-to-git-and-github-ebook

Free Introduction to Git and GitHub eBook

๐Ÿ’ก Introduction to Git and GitHub

This is an open-source introduction to Git and GitHub guide that will help you learn the basics of version control and start using Git for your SysOps, DevOps, and Dev projects. No matter if you are a DevOps/SysOps engineer, developer, or just a Linux enthusiast, you can use Git to track your code changes and collaborate with other members of your team or open source maintainers.

The guide is suitable for anyone working as a developer, system administrator, or a DevOps engineer and wants to learn the basics of Git, GitHub and version control in general.

๐Ÿš€ Download

To download a copy of the eBook use one of the following links:

๐Ÿ“˜ Chapters

This is when I came across a tool called Ibis created by Mohamed Said who is a Developer at Laravel.

Ibis allows you to generate an awesome PDF for your eBook, and you can just use markdown!

In this tutorial, I will show you how to get started with Ibis and write that eBook that you have always been planning to write!

Prerequisites

You need to have Composer installed, if you don't have it yet, you can follow the steps here:

How to install Composer

Installation

In order to install Ibis, all that you need to do is run the following composer command:

composer global require themsaid/ibis
Enter fullscreen mode Exit fullscreen mode

After the installation, you can test if the ibis command is available with the following:

ibis -V
Enter fullscreen mode Exit fullscreen mode

Once you are sure that you have the Ibis command line tool installed, you can instantiate a new project with the following command:

ibis init
Enter fullscreen mode Exit fullscreen mode

Note: Make sure to run the command in an empty directory where you would store your Markdown files later on

The init command will generate the following files:

/assets
/assets/fonts
/assets/cover.jpg
/assets/theme-light.html
/assets/theme-dark.html
/content
/ibis.php
Enter fullscreen mode Exit fullscreen mode

You can modify the /assets/theme-light.html and the /assets/theme-dark.html to change any of the styles for the eBook. For example, I like to increase the size of the text and the line spacing a little bit.

Configuration

In order to configure ibis all that you need to do is change the values in the ibis.php file.

The main settings would be:

  • title: The title of your eBook
  • author: Your anme
  • sample: Page ranges to be used with the sample command
  • sample_notice: A notice printed at the final page of a generated sample

Creating a cover photo

There is an awesome tool that you could use for free to generate your cover photo:

If you ever need to create a graphic, poster, invitation, logo, presentation โ€“ or anything that looks good โ€” give Canva a go!

To change the cover photo, just substitute the default /assets/cover.jpg with your image!

Markdown files

With the above, you can then start writing your eBook! The content would be stored in the content folder where you will have to add your Markdown files.

Ibis would read all of the .md files in the content folder and would use all h1 titles as the name of the chapters.

If you are not familiar with Markdown, make sure to check out this guide here.

Building the PDF

Once you have your content ready, in order to build the PDF of your eBook, just use the following commands

  • Light mode
ibis build
Enter fullscreen mode Exit fullscreen mode
  • Dark mode
ibis build dark
Enter fullscreen mode Exit fullscreen mode

If you want to generate a sample of your eBook use the following commands:

  • Light mode sample:
ibis sample
Enter fullscreen mode Exit fullscreen mode
  • Dark mode sample:
ibis sample dark
Enter fullscreen mode Exit fullscreen mode

Once you run the command, it will generate your PDF and store them in the export folder.

The output that you will see would look like this:

==> Preparing Export Directory ...
==> Parsing Markdown ...
==> Adding Book Cover ...
==> Building PDF ...
==> Writing PDF To Disk ...

โœจโœจ 34 PDF pages โœจโœจ

Book Built Successfully!
Enter fullscreen mode Exit fullscreen mode

Conclusion

If you like the Ibis tool, make sure to star it on GitHub and contribute!

If you publish your own eBook make sure to let me know by tagging me on Twitter @bobbyiliev_!

Hope that this helps!

Top comments (8)

Collapse
 
billraymond profile image
Bill Raymond

Thanks for sharing this! I was pondering creating my own product to do this, but sounds like it is already taken care of!

Have you seen any issues to be aware of, like images not displaying, accessibility, challenges with links, or code snippets? That sort of thing..

Thanks!

Collapse
 
bobbyiliev profile image
Bobby Iliev

Hi there ๐Ÿ‘‹,

I have been super happy with it. You have full control over the book topography by just changing a single style.css file.

Main thing that I find as a downside is that it only supports PDF.

Collapse
 
billraymond profile image
Bill Raymond

Okay, cool. Thank you. I created an ebook creation product two years ago that fully supports ePub, so will take a look at how it works.

Collapse
 
miguelcoba profile image
Miguel Cobรก

I started with markdown but now I use asciidoctor. that can generate PDF and ePubs and the syntax is equally simple as markdown. And it is also open source.

Collapse
 
mxglt profile image
Maxime Guilbert

Really interesting! Hurry to test it

Collapse
 
bobbyiliev profile image
Bobby Iliev

Awesome! Good luck! If you create an eBook make sure to share it, I would love to see it.

Collapse
 
otumianempire profile image
Michael Otu

Lovely.. this was helpful..

Collapse
 
bobbyiliev profile image
Bobby Iliev

Happy to hear that this was helpful ๐Ÿ™Œ