All Projects → digitalmoksha → motion-markdown-it

digitalmoksha / motion-markdown-it

Licence: other
Ruby/RubyMotion version of Markdown-it (CommonMark compliant parser and extendable)

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to motion-markdown-it

Remarkable
Markdown parser, done right. Commonmark support, extensions, syntax plugins, high speed - all in one. Gulp and metalsmith plugins available. Used by Facebook, Docusaurus and many others! Use https://github.com/breakdance/breakdance for HTML-to-markdown conversion. Use https://github.com/jonschlinkert/markdown-toc to generate a table of contents.
Stars: ✭ 5,252 (+12404.76%)
Mutual labels:  commonmark, markdown-it
markdown-it-github-headings
Add anchors and links to headings just like Github does
Stars: ✭ 22 (-47.62%)
Mutual labels:  commonmark, markdown-it
Texme
Self-rendering Markdown + LaTeX documents
Stars: ✭ 1,970 (+4590.48%)
Mutual labels:  commonmark
Lute
🎼 一款对中文语境优化的 Markdown 引擎,支持 Go 和 JavaScript。A structured Markdown engine that supports Go and JavaScript.
Stars: ✭ 222 (+428.57%)
Mutual labels:  commonmark
Vditor
♏ 一款浏览器端的 Markdown 编辑器,支持所见即所得(富文本)、即时渲染(类似 Typora)和分屏预览模式。An In-browser Markdown editor, support WYSIWYG (Rich Text), Instant Rendering (Typora-like) and Split View modes.
Stars: ✭ 3,773 (+8883.33%)
Mutual labels:  commonmark
Vditor
♏ 一款浏览器端的 Markdown 编辑器。
Stars: ✭ 1,742 (+4047.62%)
Mutual labels:  commonmark
Lute
🎼 一款结构化的 Markdown 引擎,支持 Go 和 JavaScript。
Stars: ✭ 211 (+402.38%)
Mutual labels:  commonmark
Editor.md
The open source embeddable online markdown editor (component).
Stars: ✭ 11,741 (+27854.76%)
Mutual labels:  commonmark
markdown-it-kbd
markdown-it plugin for keystrokes. Renders [[x]] as <kbd>x</kbd>
Stars: ✭ 25 (-40.48%)
Mutual labels:  markdown-it
Tui.editor
🍞📝 Markdown WYSIWYG Editor. GFM Standard + Chart & UML Extensible.
Stars: ✭ 14,016 (+33271.43%)
Mutual labels:  commonmark
Markdownlint
A Node.js style checker and lint tool for Markdown/CommonMark files.
Stars: ✭ 2,828 (+6633.33%)
Mutual labels:  commonmark
Markdown
CommonMark-compliant markdown parser and renderer in Go. This repository has moved to https://gitlab.com/golang-commonmark/markdown
Stars: ✭ 180 (+328.57%)
Mutual labels:  commonmark
Markdown It
Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed
Stars: ✭ 12,638 (+29990.48%)
Mutual labels:  commonmark
Markdig
A fast, powerful, CommonMark compliant, extensible Markdown processor for .NET
Stars: ✭ 2,730 (+6400%)
Mutual labels:  commonmark
Down
Blazing fast Markdown / CommonMark rendering in Swift, built upon cmark.
Stars: ✭ 1,895 (+4411.9%)
Mutual labels:  commonmark
autobadge
Simple CLI tool to generate essential repository badges with ease
Stars: ✭ 16 (-61.9%)
Mutual labels:  markdown-it
Mdme
Self-rendering Markdown content
Stars: ✭ 140 (+233.33%)
Mutual labels:  commonmark
Commonmark
Highly-extensible PHP Markdown parser which fully supports the CommonMark and GFM specs.
Stars: ✭ 2,128 (+4966.67%)
Mutual labels:  commonmark
Markdownui
Render Markdown text in SwiftUI
Stars: ✭ 207 (+392.86%)
Mutual labels:  commonmark
markdown
The first generation of Markdown rendering for R (born in 2012). Now R Markdown usually means the *r*markdown package instead of *markdown*. The repo for the former is at https://github.com/rstudio/rmarkdown
Stars: ✭ 64 (+52.38%)
Mutual labels:  commonmark

motion-markdown-it

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 8.4.1


Javascript Live demo

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

Benefit

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

Performance is slower than, say, kramdown, but for most uses, is pretty fast. Here are some non-scientific benchmarks. Note that kramdown and redcarpet are not CommonMark compliant.

Running tests on 2018-04-04 under ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]

==> Test using file mdsyntax.text and 500 runs
Rehearsal -------------------------------------------------------------
motion-markdown-it 8.4.1   17.940000   0.710000  18.650000 ( 18.721629)
kramdown 1.16.2            14.720000   0.180000  14.900000 ( 15.015840)
commonmarker 0.17.9         0.220000   0.000000   0.220000 (  0.222098)
redcarpet 3.4.0             0.140000   0.010000   0.150000 (  0.145821)
--------------------------------------------------- total: 33.920000sec

                                user     system      total        real
motion-markdown-it 8.4.1   18.290000   0.720000  19.010000 ( 19.113943)
kramdown 1.16.2            13.320000   0.110000  13.430000 ( 13.459096)
commonmarker 0.17.9         0.190000   0.000000   0.190000 (  0.187104)
redcarpet 3.4.0             0.120000   0.000000   0.120000 (  0.123931)

Real time as a factor of motion-markdown-it
motion-markdown-it 8.4.1    1.0
kramdown 1.16.2             0.7042
commonmarker 0.17.9         0.0098
redcarpet 3.4.0             0.0065

Table of content

Install

Ruby

Add it to your project's Gemfile

gem 'motion-markdown-it'

and run bundle install

RubyMotion

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

Simple

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

Single line rendering, without paragraph wrap:

result = MarkdownIt::Parser.new.renderInline('__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 = MarkdownIt::Parser.new(:commonmark)

#--- default mode
parser = MarkdownIt::Parser.new

#--- enable everything
parser = MarkdownIt::Parser.new({ html: true, linkify: true, typographer: true })

#--- full options list (defaults)
parser = MarkdownIt::Parser.new({
  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 externally.
  highlight: lambda {|str, lang| return nil}
})

Plugins

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:

Upgrading

Upgrading to 8.4.1.2 could cause some small breakage if you are using any custom plugins. The motion-markdown-it-plugins plugins have already been upgraded.

charCodeAt

Make sure you have

include MarkdownIt::Common::Utils

at the top of your plugin file. Then change any references to charCodeAt. For example,

state.src.charCodeAt(pos)

would become

charCodeAt(state.src, pos)

slice_to_end

slice_to_end has been removed. Change references like this

state.src.slice_to_end(pos)

to

state.src[pos..-1]

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:

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].