Giter Club home page Giter Club logo

maruku's Introduction

Maruku

Maruku is a Markdown-superset interpreter.

Maruku implements:

  • The original Markdown syntax.
  • All the improvements in PHP Markdown Extra.
  • A new meta-data syntax.

Read more about Maruku's Markdown syntax. It also supports inline math. Maruku docs.

News about Maruku is posted at http://benhollis.net/blog/category/maruku/

Build Status Gem Version Dependency Status Code Climate Coverage Status

Installing

Make sure you have Ruby and RubyGems, then run:

gem install maruku

Basic use

To convert Markdown from your Ruby programs, first create a new document and then get its HTML representation with the method to_html:

doc = Maruku.new(markdown_string)
puts doc.to_html

The #to_html method returns a string, representing an HTML fragment.

Maruku.new("## Header ##").to_html
# => "<h2 id='header'>header</h2>"

If you want to create full HTML documents, use the #to_html_document method.

Error Management

Maruku warns you if something is wrong with the input. The default behaviour is to print a warning on standard error, and then try to continue.

This behavior can be customized with the :on_error option. For example:

Maruku.new(string, :on_error => :raise)

This tells Maruku to raise an exception if it encounters a parsing error.

To change the error stream, use the :error_stream option:

errors = "Errors reported by Maruku:\n"
Maruku.new(invalid, :error_stream => errors)

You can pass in any object that supports the << method.

Command-line usage

Maruku comes with two command-line programs: maruku and marutex.

maruku converts Markdown to HTML:

$ maruku file.md  # creates file.html

marutex converts Markdown to LaTeX, then calls pdflatex to transform the LaTeX to a PDF:

$ marutex file.md  # creates file.tex and file.pdf

Code organization

The public interface is the Maruku class. Everything else is in the module MaRuKu.

Dependencies

Maruku will not depend on any gem that is not pure-Ruby. This helps maximize compatibility across Ruby implementations and make Maruku easy to use. Beyond that, Maruku should not depend on any other gem unless absolutely necessary - this make Maruku easy to consume and avoids dependency version conflicts.

Supported Ruby Versions

This library aims to support and is tested against the following Ruby implementations:

  • Ruby 1.8.7
  • Ruby 1.9.2
  • Ruby 1.9.3
  • Ruby 2.0.0
  • JRuby (Travis' version, 1.8 and 1.9 modes)
  • Rubinius (Travis' version, 1.8 and 1.9 modes)

If something doesn't work on one of these interpreters, it's a bug.

Contributing

  • Find something you would like to work on.
  • Fork the project and do your work in a topic branch.
    • Make sure your changes will work on all the Rubies we test on.
  • Add tests in spec/block_docs for the behavior you want to test.
  • Run all the tests using bundle exec rake.
  • Rebase your branch against bhollis/maruku to make sure everything is up to date.
  • Commit your changes and send a pull request.

License

Copyright (c) 2006 Andrea Censi. MIT license, see MIT-LICENSE.txt for details.

maruku's People

Contributors

bhollis avatar nex3 avatar distler avatar kachick avatar bprescott avatar stomar avatar stepheneb avatar eagleas avatar bmichelsen avatar pdlug avatar brettgoulder avatar lastland avatar

Watchers

Vipul A M avatar

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.