Giter VIP home page Giter VIP logo

maliq's Introduction

Maliq

Maliq is a markdown, liquid converter for EPUB's xhtml.

It comes with two command 'maliq' and 'maliq_gepub'. 'maliq' is a markdown-xhtml converter and 'maliq_gepub' is a wrapper of gepub gem which is a EPUB generator.

Installation

Add this line to your application's Gemfile:

gem 'maliq'

And then execute:

$ bundle

Or install it yourself as:

$ gem install maliq

Commands Usage

Follow the steps below:

  1. Provide your content with markdown format. (ex. chapter01.md)

  2. Write meta data required for EPUB in the head of the file with Yaml Front Matter(YFM) form(see below).

  3. You can obtain separated xhtml files each of which represents a chapter from a markdown file if needed. This achive by placing a special marker into target line of your content. The Default marker is <<<--- <filename> --->>> (ex. <<<--- chapter02 --->>>). When filenames are omitted, system generate sequential names automatically for them.

  4. Place css and image files into the directory or its sub directory if any.

  5. Place liquid plugins into the sub directory named 'plugins'(default) when your content include liquid tags.

  6. Fire up maliq command followed by the filename(s) on the current directory. (ex. maliq chapter01.md) This create xhtml file(s).

  7. Install Gepub gem (gem install gepub), then fire up maliq_gepub command to generate a EPUB package.

Yaml Front Matter Sample

The front matter must be the first thing in the file and takes the form of:

---
language: 'en'
unique_identifier:
 - 'http:/example.jp/bookid_in_url'
 - 'BookID'
 - 'URL'
title: 'Book of Charlie'
subtitle: 'Where Charlie goes to'
creator: 'melborne'
date: '2012-01-01'
---

Between the triple-dashed lines, you can set predefined variables.

Liquid plugins

There are many liquid plugins on the Net, but you might need to modify them to be work for Epub generation. Some my modified plugins are there:

Liquid filters for Maliq gem to generate xhtml โ€” Gist

Code Usage

Pass markdown string to Maliq::Converter.new.

puts Maliq::Converter.new("#header1\nline1\n\nline2").run

This get:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="ja">
  <head>
    <title></title>
    
  </head>
  <body>
    <h1>header1</h1>

    <p>line1</p>

    <p>line2</p>
  </body>
</html>

To make liquid tags parsed with plugins, specify a plugin folder at the front matter or set by #set_meta. It is not required when the folder is 'plugins'(default).

Maliq::Converter.new(<<-EOS).run(false)
---
liquid: 'filters'
---
# header1
{% calc 2 + 3 %}
EOS

This produce followings, with calc.rb plugin at a folder named 'filters'.

<h1>header1</h1>

<p>2 + 3 = 5</p>

Thank you

Thank you to Satoshi KOJIMA for creating Ggepub which is a great EPUB generator.

Thank you to rtomayko (Ryan Tomayko) for creating Rdiscount which is a great markdown parser.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

maliq's People

Contributors

melborne avatar igaiga avatar udzura avatar

Stargazers

Atsushi Yamaguchi avatar Hiromichi NOMATA avatar Gerald Bauer avatar Hibariya avatar Thomas Yang avatar Keisuke KITA avatar KITAITI Makoto avatar Wataru MIYAGUNI avatar Chun-wei Kuo avatar Yosuke TOMITA avatar Hiroshi Saito avatar

Watchers

 avatar KITAITI Makoto avatar James Cloos avatar

Forkers

udzura igaiga

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.