Ruby/RubyMotion version of Markdown-it (CommonMark compliant parser and extendable)
Failed to load latest commit information.
benchmark Initial commit Mar 27, 2015
lib use linkify-it-rb 1.2.0 Nov 14, 2016
rubymotion synchronize with markdown-it 4.4.0 Nov 14, 2016
spec use linkify-it-rb 1.2.0 Nov 14, 2016
.rspec Initial commit Mar 27, 2015
.travis.yml attempt travis build again Jun 20, 2015


Gem Version Build Status Ruby/RubyMotion version of Markdown-it (CommonMark compliant and extendable)

This gem is a port of the markdown-it Javascript package by Vitaly Puzrin and Alex Kocharin. Currently synced with markdown-it 4.4.0

Javascript Live demo

Follows the CommonMark spec + adds syntax extensions & sugar (URL autolinking, typographer).


The benefit of this project, for me at least, is to have a standardized CommonMark compliant, fast, and extendable, Markdown parser which can be used from Javascript, Ruby, and/or RubyMotion, as the development situation warrants.


Performance is still an issue. While it performs reasonably well with small to medium files, it degrades for large files. Work in progress...

Table of content



Add it to your project's Gemfile

gem 'motion-markdown-it'

and run bundle install


Add it to your project's Gemfile

gem 'motion-markdown-it'

Edit your Rakefile and add

require 'motion-markdown-it'

and run bundle install

Usage examples


parser =, { html: false })
parser.render('# markdown-it in **Ruby**')

Single line rendering, without paragraph wrap:

result ='__markdown-it__ in Ruby')

Init with presets and options

(*) presets define combinations of active rules and options. Can be :commonmark, :zero or :default (if skipped).

#--- commonmark mode
parser =

#--- default mode
parser =

#--- enable everything
parser ={ html: true, linkify: true, typographer: true })

#--- full options list (defaults)
parser ={
  html:         false,        # Enable HTML tags in source
  xhtmlOut:     false,        # Use '/' to close single tags (<br />).
                              # This is only for full CommonMark compatibility.
  breaks:       false,        # Convert '\n' in paragraphs into <br>
  langPrefix:   'language-',  # CSS language prefix for fenced blocks. Can be
                              # useful for external highlighters.
  linkify:      false,        # Autoconvert URL-like text to links

  # Enable some language-neutral replacement + quotes beautification
  typographer:  false,

  # Double + single quotes replacement pairs, when typographer enabled,
  # and smartquotes on. Could be either a String or an Array.
  # For example, you can use '«»„“' for Russian, '„“‚‘' for German,
  # and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
  quotes: '“”‘’',

  # Highlighter function. Should return escaped HTML,
  # or nil if the source string is not changed and should be escaped externaly.
  highlight: lambda {|str, lang| return nil}


Plugins can be used to extend the syntax and functionality. A sample set of plugins has been created based on those already created for the javascript version. Included are:

References / Thanks

Thanks to the authors of the original implementation in Javascript, markdown-it:

and to John MacFarlane for his work on the CommonMark spec and reference implementations.

Related Links: