Fast, pure-Ruby Markdown-superset converter
open sourceMITself-hostablefree
kramdown is a pure Ruby library that parses a superset of Markdown, with extensions popularised by PHP Markdown Extra and Maruku (tables, footnotes, definition lists, attribute lists, abbreviations, math), into an element tree and converts it. It reads kramdown, standard Markdown, HTML and, through the kramdown-parser-gfm gem (built in until 2.0), GitHub Flavored Markdown, and writes HTML, LaTeX, kramdown, man pages or text without HTML tags. Code blocks can be highlighted with Rouge and math rendered with MathJax or KaTeX. It ships a kramdown command, and Thomas Leitner has maintained it since 2009; it moved from the GPL to the MIT licence at 1.0.
Problems it solves
- convert Markdown to HTML in Ruby without a C extension
- render GitHub-style Markdown with fenced code blocks and strikethrough in my Ruby app
- I need tables, footnotes and definition lists in Markdown, not just the basics
- add CSS classes and ids to Markdown headings and paragraphs
- turn Markdown documents into LaTeX so I can typeset a PDF
- write man pages in Markdown and generate groff output
- convert existing HTML back into Markdown text
- highlight code blocks in Markdown with Pygments-style CSS
- render math formulas in Markdown with KaTeX on the server
- get automatic ids on headings and a generated table of contents
- strip the HTML out of a Markdown document to get plain text
- convert Markdown files from the command line in a build script
Features
- kramdown syntax: tables, footnotes, definition lists, abbreviations, attribute lists, math blocks
- parsers for kramdown, Markdown, HTML and GitHub Flavored Markdown (kramdown-parser-gfm)
- converters to HTML, LaTeX, kramdown, man pages and RemoveHtmlTags
- syntax highlighting with Rouge (built in) or CodeRay (kramdown-syntax-coderay)
- math engines including MathJax and KaTeX
- automatic header ids and table of contents
- typographic conversions such as smart quotes and dashes
- kramdown command for converting files or standard input
- GFM options for hard wraps, GitHub quirks and emoji
- element tree API for custom parsers and converters
Capabilities
| Has an API | plan not known |
|---|---|
| Has a command line tool | plan not known |
