kramdown Documentation
Overview
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:
-
Input: kramdown (a superset of Markdown), Markdown, Github Flavored Markdown, HTML
-
Output: HTML, LaTeX, kramdown, RemoveHtmlTags (a special converter which removes HTML tags, normally used in conjunction with the LaTeX or kramdown converters)
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!
Usage
The kramdown package provides two ways for using it:
-
As a library
kramdown uses basically the same API as RedCloth, BlueCloth and Maruku:
require 'kramdown' puts Kramdown::Document.new(text).to_html
The second parameter to the
new
call 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:input
option: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
kramdown
is 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:kramdown path/to/kramdown/doc/syntax.page
The input and output formats as well as all available kramdown options are supported through command line switches.
Tests
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.