grunt-epubmk

1.0.0 • Public • Published

grunt-epubmk

The epub maker

Getting Started

This plugin requires Grunt ~0.4.5

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-epubmk --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-epubmk');

The "epubmk" task

Overview

In your project's Gruntfile, add a section named epubmk to the data object passed into grunt.initConfig().

grunt.initConfig({

    epubmk: {
      default: {
        options: {            
          src: 'epubsrc',
          textsrc: 'epubsrc/OEBPS',
          author: 'Author Name',
          title: 'Novel Title',
          identifier: 'isbn:000000100100100',
          language: 'it-IT'
        },
        files: [
            {
              src: [
                'epubsrc/OEBPS/chapter001.html',
                'epubsrc/OEBPS/chapter002.html',
                'epubsrc/OEBPS/chapter003.html'
                ...
              ]
            }
          ]
        } 
    },

});

Options

options.src

Type: String Default value: epubsrc

Main source folder containing all ebook files.

options.textsrc

Type: String Default value: epubsrc/OEBPS

Subfolder containing xhtml files of chapters.

Usage Examples

grunt.initConfig({

    epubmk: {
      default: {
        options: {            
          src: 'epubsrc',
          textsrc: 'epubsrc/OEBPS',
          author: 'Author Name',
          title: 'Novel Title',
          identifier: 'isbn:000000100100100',
          language: 'it-IT'
        },
        files: [
            {
              src: [
                'epubsrc/OEBPS/chapter001.html',
                'epubsrc/OEBPS/chapter002.html',
                'epubsrc/OEBPS/chapter003.html'
                ...
              ]
            }
          ]
        } 
    },

    handlebars: {
        "templates/templates.js": ["templates/*.hbs"]
    },

    shell: {
        multiple: {
            command: [
                'cd epubsrc',
                'zip -0 myebook.epub mimetype',
                'zip -9 -r myebook.epub META-INF OEBPS'
            ].join('&&')
        }
    }

});

Using epubcheck

Using epubcheck https://github.com/IDPF/epubcheck on Linux or OS X. Add those lines to Grunt config file:

    shell: {
        multiple: {
            command: [
                'cd epubsrc',
                'zip -9 -rX myebook.epub mimetype META-INF OEBPS',
                'cd ..',
                'java -jar epubcheck-3.0.1.jar epubsrc/myebook.epub'
            ].join('&&')
        }
    },

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

(Nothing yet)

A plugin to create epub files from a folder within html files.

Readme

Keywords

Package Sidebar

Install

npm i grunt-epubmk

Weekly Downloads

1

Version

1.0.0

License

none

Last publish

Collaborators

  • antonioagrestini