Maruku is a Markdown-superset interpreter.
Maruku implements:
- The original Markdown syntax.
- All the improvements in PHP Markdown Extra.
- A new meta-data syntax.
This branch also provides support for tables with colspans using empty pipe characters
If you want to span a column you just need to do the following:
| h1 | h2 | h3 | |:----------|:---:|-----:| |c1 | c2 | c3 | |c1 | c2 || |c1 || c2 | |c1 |||
This is a somewhat cleaner version of the standard syntax that is supported in Maruku
| h1 | h2 | h3 | |:--------------|:---------:|----------:| |c1 | c2 | c3 | |c1 |{:colspan="2"} c2 | |{:colspan="2"} c1 | c2 | |{:colspan="3"} c1 |
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/
The basic use is to create a new document, and then write
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>"
This is useful for using Maruku inside other programs.
If you want to create full HTML documents,
use the #to_html_document
method.
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.
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
The public interface is the Maruku
class.
Everything else is in the module MaRuKu
.
Copyright (c) 2006 Andrea Censi. MIT license, see MIT-LICENSE.txt for details.