All projects

ebook_compiler

simple utility that converts .md (markdown) files to html then combines them into one ebook .html file

This is a simple utility that converts .md (markdown) files to html. It then combines them into one ebook .html file.

The real benefit of this is that I can separate my ebook into separate files. As many or as few as I want. I currently have split up my little ebook into chapters and sub-sections; one file each.

This little utility will only convert md files that have changed, into html. Once all html files are up to date, they are combined into a single file and wrapped inside the template.

Config file

It supports a config file for specifying compile settings and a template file. Here is an example config file.

_ebook_compiler.config

    title=My ebook title
    ext=*.md
    toc=5_toc.html
    zip=_ebook.zip
    resource_folder=resources
    resource=*.png
    output_filenames=true
    template=_ebook_template.txt
    markdown_compiler=C:\YourPath\Markdown.bat

Config options

Template file

The template file is really just an html file. Use @SPLIT@ to indicate in the template where the ebook contents will be. See the following for an example template. This is really just to provide some basic styles and overhead for your ebook.

_ebook_template.html

    <html>
    <head>
      <title>My ebook title</title>
      <style media="all">
        * {
          color: #333;
        }

        body {
          /*line-height: 1.2em;*/
        }

        p {
          display: block;
          margin-top: 1em;
          margin-bottom: 1em;
        }

        /* ... */

        pre {
          background-color: #f0f0f0;
        }
      </style>
    </head>
    <body>
      @SPLIT@
    </body>
    </html>

Dependencies

Summary

It is definitely a work in progress, but it does what I need for the ebook I'm working on. And, it is 100 times faster than editing a single md file and converting the whole thing every time.

This is NOT a markdown to html compiler

It relies upon some other markdown to html converter. I use a simple batch file that wraps the markdown.pl (a Perl script) available from daring fireball for the actual conversion.