A command line tool that parses a folder of markdown files into a digital book
- Clone this repository and
cd
into itgit clone http://github.com/kvendrik/mdown-to-book.git && cd mdown-to-book
- Install the dependencies:
sudo gem install redcarpet json
- Make sure the current file order of your markdown files represents the structure for the book.
- (Optional) Create a
book-settings.json
file in the directory with your markdown files. - Run
./parse <path to your markdown files>
- You can find the book in
<path to your markdown files>/book-output/book/
cd
into the output directorycd <path to your markdown files>/book-output/
- Run
npm install
to install all the needed dependencies to customize the theme - Run
grunt serve
(make sure you have the grunt-cli installed) - A new browser tab will open. You can now start modifying the theme while Grunt takes care of the rest. (pre-processing SASS, merging JS files, etc.)
Each file will be parsed to a new page in your book and will be considered a chapter. The filename will be used as the name for that chapter. To create the desired order you prepend your filenames with numbers e.g. 1_Introduction.md
, 1.1_Sub Introduction
. The first file in the folder will be used as cover page. We automatically generate a table of contents based on the chapters.
The book-settings.json
file accepts the options below. In case the book-settings.json
file could not be found or one of the options is not defined the script uses default values to fill in the blanks.
{
"title": "My Digital Book",
"contents-table": "Table of Contents",
"footer": "A book generated by <a href='http://github.com/kvendrik/mdown-to-book'>Markdown to book</a> by <a href='http://github.com/kvendrik/'>Koen Vendrik</a> && <a href='http://github.com/mattivdweem'>Matti van de Weem</a>.",
"buttons": {
"next": "Next",
"previous": "Previous"
}
}
Option | Type | Description |
---|---|---|
title | String | The title for your book |
contents-table | String | Text to use as title for the table of contents |
footer | String | The footer text to appear on the bottom of every page |
buttons | Object | Accepts a next and a previous option that each take a string to use as text on the navigation buttons |
In your markdown you can use img/<image filename>
as the src
for your images. Then after you parsed your book you can manually place the images in <path to your markdown files>/book-output/book/img/