kramdown is first and foremost a library for converting text written in a superset of Markdown to HTML. However, due to its modular architecture it is able to support additional input and output formats. The following input and output formats are currently supported:
The kramdown syntax page describes in detail what is supported and how it differs from standard Markdown.
For all available options have a look at the options documentation or have a look at a parser/converter page to see which options they support!
The kramdown package provides two ways for using it:
As a library
require 'kramdown' puts Kramdown::Document.new(text).to_html
The second parameter to the
newcall is an options hash for (de)activating certain features. For example, to disable automatic header ID generation, you can do the following:
puts Kramdown::Document.new(text, :auto_ids => false).to_html
The default parser used is
kramdown, however, you can select a different one with the
puts Kramdown::Document.new(text, :input => 'html').to_latex
You can also reuse the created document object to produce multiple outputs:
doc = Kramdown::Document.new(text, :input => 'html') puts doc.to_html puts doc.to_latex
More information on how to use or extend kramdown can be found in the API documentation!
As an application
Together with the library files a binary called
kramdownis shipped which can be used to convert text in any supported input format to any supported output format. It either reads from the files specified as the command line arguments or from the standard input. For example:
The input and output formats as well as all available kramdown options are supported through command line switches.
kramdown uses various test suites to verify the correct working of the parsers and converters. For more information, have a look at the tests document.