A pure-Ruby Markdown-superset interpreter (Official Repo).
Ruby
504
537 commits
updated Jan 5, 2025
Maruku is a Markdown-superset interpreter.
Maruku implements:
Read more about Maruku's Markdown syntax. It also supports inline math. Maruku docs.
Note: Maruku should be considered obsolete, as it has been superceded by better libraries like Kramdown.
Make sure you have Ruby and RubyGems, then run:
gem install maruku
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.
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.
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.
Maruku follows Semantic Versioning for release versioning, starting around version 0.6.0. One caveat is that, because even the most minor bug fixes are likely to change the output of some documents, some of the patch-level changes are not strictly backwards compatible. This usually shows up as test breakages, and one suggestion is to use a tool like nokogiri-diff to compare output to the expected structure as XML rather than simply comparing strings.
This library aims to support and is tested against the following Ruby implementations:
If something doesn't work on one of these interpreters, it's a bug.
spec/block_docs for the behavior you want to test.bundle exec rake.bhollis/maruku to make sure everything is up to date.Copyright (c) 2006 Andrea Censi. MIT license, see MIT-LICENSE.txt for details.
1,341 followers · starred Oct 2018
33 followers · starred Feb 2011
168 followers · starred Mar 2014
47 followers · starred Apr 2009
A pure-Ruby Markdown-superset interpreter (Official Repo).
Ruby
504
537 commits
updated Jan 5, 2025
Maruku is a Markdown-superset interpreter.
Maruku implements:
Read more about Maruku's Markdown syntax. It also supports inline math. Maruku docs.
Note: Maruku should be considered obsolete, as it has been superceded by better libraries like Kramdown.
Make sure you have Ruby and RubyGems, then run:
gem install maruku
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.
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.
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.
Maruku follows Semantic Versioning for release versioning, starting around version 0.6.0. One caveat is that, because even the most minor bug fixes are likely to change the output of some documents, some of the patch-level changes are not strictly backwards compatible. This usually shows up as test breakages, and one suggestion is to use a tool like nokogiri-diff to compare output to the expected structure as XML rather than simply comparing strings.
This library aims to support and is tested against the following Ruby implementations:
If something doesn't work on one of these interpreters, it's a bug.
spec/block_docs for the behavior you want to test.bundle exec rake.bhollis/maruku to make sure everything is up to date.Copyright (c) 2006 Andrea Censi. MIT license, see MIT-LICENSE.txt for details.
1,341 followers · starred Oct 2018
33 followers · starred Feb 2011
168 followers · starred Mar 2014
47 followers · starred Apr 2009