{"id":17310604,"url":"https://github.com/digitalmoksha/motion-markdown-it","last_synced_at":"2025-07-06T14:33:16.377Z","repository":{"id":29354648,"uuid":"32888923","full_name":"digitalmoksha/motion-markdown-it","owner":"digitalmoksha","description":"Ruby/RubyMotion version of Markdown-it (CommonMark compliant parser and extendable)","archived":false,"fork":false,"pushed_at":"2024-05-23T19:32:55.000Z","size":452,"stargazers_count":50,"open_issues_count":0,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-06-28T21:15:59.313Z","etag":null,"topics":["commonmark","markdown","markdown-it","ruby","rubymotion"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/digitalmoksha.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-03-25T20:26:51.000Z","updated_at":"2025-04-01T10:32:15.000Z","dependencies_parsed_at":"2024-10-30T11:03:50.099Z","dependency_job_id":"1214be3f-b76b-4b2e-b42e-de196cd23717","html_url":"https://github.com/digitalmoksha/motion-markdown-it","commit_stats":{"total_commits":73,"total_committers":2,"mean_commits":36.5,"dds":0.04109589041095896,"last_synced_commit":"37443f70f6d4ba5c9dda6962dec02a306d21608f"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/digitalmoksha/motion-markdown-it","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalmoksha%2Fmotion-markdown-it","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalmoksha%2Fmotion-markdown-it/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalmoksha%2Fmotion-markdown-it/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalmoksha%2Fmotion-markdown-it/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitalmoksha","download_url":"https://codeload.github.com/digitalmoksha/motion-markdown-it/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalmoksha%2Fmotion-markdown-it/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263763679,"owners_count":23507633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["commonmark","markdown","markdown-it","ruby","rubymotion"],"created_at":"2024-10-15T12:37:48.184Z","updated_at":"2025-07-06T14:33:16.352Z","avatar_url":"https://github.com/digitalmoksha.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# motion-markdown-it\n\n[![Gem Version](https://badge.fury.io/rb/motion-markdown-it.svg)](http://badge.fury.io/rb/motion-markdown-it)\n[![Build Status](https://github.com/digitalmoksha/motion-markdown-it/actions/workflows/ci.yml/badge.svg)](https://github.com/digitalmoksha/motion-markdown-it/actions/workflows/ci.yml)\n\nRuby/RubyMotion version of Markdown-it (CommonMark compliant and extendable)\n\nThis gem is a port of the [markdown-it Javascript package](https://github.com/markdown-it/markdown-it) by Vitaly Puzrin and Alex Kocharin. \n\n_Currently synced with markdown-it 13.0.1_\n\n---\n\n__[Javascript Live demo](https://markdown-it.github.io)__\n\nFollows the __[CommonMark spec](http://spec.commonmark.org/)__ + adds syntax extensions \u0026 sugar (URL autolinking, typographer).\n- Configurable syntax. You can add new rules and even replace existing ones.\n- [Safe](https://github.com/markdown-it/markdown-it/tree/master/docs/security.md) by default.\n- Community-written plugins\n  * [Ruby/RubyMotion](https://github.com/digitalmoksha/motion-markdown-it-plugins)\n  * [original javascript plugins](https://www.npmjs.org/browse/keyword/markdown-it-plugin) and [other packages](https://www.npmjs.org/browse/keyword/markdown-it) on npm.\n\n## Benefit\n\nThe 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.\n\n## Performance\n\nPerformance 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.\n\n```\nRunning tests on 2018-04-04 under ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]\n\n==\u003e Test using file mdsyntax.text and 500 runs\nRehearsal -------------------------------------------------------------\nmotion-markdown-it 8.4.1   17.940000   0.710000  18.650000 ( 18.721629)\nkramdown 1.16.2            14.720000   0.180000  14.900000 ( 15.015840)\ncommonmarker 0.17.9         0.220000   0.000000   0.220000 (  0.222098)\nredcarpet 3.4.0             0.140000   0.010000   0.150000 (  0.145821)\n--------------------------------------------------- total: 33.920000sec\n\n                                user     system      total        real\nmotion-markdown-it 8.4.1   18.290000   0.720000  19.010000 ( 19.113943)\nkramdown 1.16.2            13.320000   0.110000  13.430000 ( 13.459096)\ncommonmarker 0.17.9         0.190000   0.000000   0.190000 (  0.187104)\nredcarpet 3.4.0             0.120000   0.000000   0.120000 (  0.123931)\n\nReal time as a factor of motion-markdown-it\nmotion-markdown-it 8.4.1    1.0\nkramdown 1.16.2             0.7042\ncommonmarker 0.17.9         0.0098\nredcarpet 3.4.0             0.0065\n````\n\n## Table of content\n\n- [Install](#install)\n- [Usage examples](#usage-examples)\n  - [Simple](#simple)\n  - [Init with presets and options](#init-with-presets-and-options)\n- [Plugins](#plugins)\n- [Upgrading](#upgrading)\n- [References / Thanks](#references--thanks)\n- [License](#license)\n\n\u003c!--\n- [API](#api)\n- [Syntax extensions](#syntax-extensions)\n- [Benchmark](#benchmark)\n--\u003e\n\n## Install\n\n### Ruby\n\nAdd it to your project's `Gemfile`\n\n\tgem 'motion-markdown-it'\n\nand run `bundle install`\n\n### RubyMotion\n\nAdd it to your project's `Gemfile`\n\n\tgem 'motion-markdown-it'\n\nEdit your `Rakefile` and add\n\n\trequire 'motion-markdown-it'\n\nand run `bundle install`\n\n\n## Usage examples\n\n### Simple\n\n```ruby\nparser = MarkdownIt::Parser.new(:commonmark, { html: false })\nparser.render('# markdown-it in **Ruby**')\n```\n\nSingle line rendering, without paragraph wrap:\n\n```ruby\nresult = MarkdownIt::Parser.new.renderInline('__markdown-it__ in Ruby')\n```\n\n### Init with presets and options\n\n(*) presets define combinations of active rules and options. Can be\n`:commonmark`, `:zero` or `:default` (if skipped).\n\n```ruby\n#--- commonmark mode\nparser = MarkdownIt::Parser.new(:commonmark)\n\n#--- default mode\nparser = MarkdownIt::Parser.new\n\n#--- enable everything\nparser = MarkdownIt::Parser.new({ html: true, linkify: true, typographer: true })\n\n#--- full options list (defaults)\nparser = MarkdownIt::Parser.new({\n  html:         false,        # Enable HTML tags in source\n  xhtmlOut:     false,        # Use '/' to close single tags (\u003cbr /\u003e).\n                              # This is only for full CommonMark compatibility.\n  breaks:       false,        # Convert '\\n' in paragraphs into \u003cbr\u003e\n  langPrefix:   'language-',  # CSS language prefix for fenced blocks. Can be\n                              # useful for external highlighters.\n  linkify:      false,        # Autoconvert URL-like text to links\n\n  # Enable some language-neutral replacement + quotes beautification\n  # For the full list of replacements, see https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js\n  typographer:  false,\n\n  # Double + single quotes replacement pairs, when typographer enabled,\n  # and smartquotes on. Could be either a String or an Array.\n  #\n  # For example, you can use '«»„“' for Russian, '„“‚‘' for German,\n  # and ['«\\xA0', '\\xA0»', '‹\\xA0', '\\xA0›'] for French (including nbsp).\n  quotes: '“”‘’',\n\n  # Highlighter function. Should return escaped HTML,\n  # or nil if the source string is not changed and should be escaped externally.\n  highlight: lambda {|str, lang| return nil}\n})\n```\n\n## Plugins\n\nPlugins can be used to extend the syntax and functionality.  A [sample set of plugins](https://github.com/digitalmoksha/motion-markdown-it-plugins) has been created based on those already created for the javascript version.  Included are:\n\n* [Abbreviations](https://github.com/digitalmoksha/motion-markdown-it-plugins/tree/master/lib/motion-markdown-it-plugins/abbr)\n* [Checkbox/Tasklists](https://github.com/digitalmoksha/motion-markdown-it-plugins/tree/master/lib/motion-markdown-it-plugins/checkbox_replace)\n* [Containers](https://github.com/digitalmoksha/motion-markdown-it-plugins/tree/master/lib/motion-markdown-it-plugins/container)\n* [Definition Lists](https://github.com/digitalmoksha/motion-markdown-it-plugins/tree/master/lib/motion-markdown-it-plugins/deflist)\n* [Insert](https://github.com/digitalmoksha/motion-markdown-it-plugins/tree/master/lib/motion-markdown-it-plugins/ins)\n* [Mark](https://github.com/digitalmoksha/motion-markdown-it-plugins/tree/master/lib/motion-markdown-it-plugins/mark)\n* [Subscript](https://github.com/digitalmoksha/motion-markdown-it-plugins/tree/master/lib/motion-markdown-it-plugins/sub)\n* [Superscript](https://github.com/digitalmoksha/motion-markdown-it-plugins/tree/master/lib/motion-markdown-it-plugins/sup)\n\n\u003c!--\n### Plugins load\n\n```js\nvar md = require('markdown-it')()\n            .use(plugin1)\n            .use(plugin2, opts, ...)\n            .use(plugin3);\n```\n\n\n### Syntax highlighting\n\nApply syntax highlighting to fenced code blocks with the `highlight` option:\n\n```js\nvar hljs = require('highlight.js'); // https://highlightjs.org/\n\n// Actual default values\nvar md = require('markdown-it')({\n  highlight: function (str, lang) {\n    if (lang \u0026\u0026 hljs.getLanguage(lang)) {\n      try {\n        return hljs.highlight(str, { language: lang }).value;\n      } catch (__) {}\n    }\n\n    return ''; // use external default escaping\n  }\n});\n```\n\nOr with full wrapper override (if you need assign class to `\u003cpre\u003e`):\n\n```js\nvar hljs = require('highlight.js'); // https://highlightjs.org/\n\n// Actual default values\nvar md = require('markdown-it')({\n  highlight: function (str, lang) {\n    if (lang \u0026\u0026 hljs.getLanguage(lang)) {\n      try {\n        return '\u003cpre class=\"hljs\"\u003e\u003ccode\u003e' +\n               hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +\n               '\u003c/code\u003e\u003c/pre\u003e';\n      } catch (__) {}\n    }\n\n    return '\u003cpre class=\"hljs\"\u003e\u003ccode\u003e' + md.utils.escapeHtml(str) + '\u003c/code\u003e\u003c/pre\u003e';\n  }\n});\n```\n\n### Linkify\n\n`linkify: true` uses [linkify-it](https://github.com/markdown-it/linkify-it). To\nconfigure linkify-it, access the linkify instance through `md.linkify`:\n\n```js\nmd.linkify.set({ fuzzyEmail: false });  // disables converting email to link\n```\n\n\n## API\n\n__[API documentation](https://markdown-it.github.io/markdown-it/)__\n\nIf you are going to write plugins - take a look at\n[Development info](https://github.com/markdown-it/markdown-it/tree/master/docs).\n\n\n## Syntax extensions\n\nEmbedded (enabled by default):\n\n- [Tables](https://help.github.com/articles/organizing-information-with-tables/) (GFM)\n- [Strikethrough](https://help.github.com/articles/basic-writing-and-formatting-syntax/#styling-text) (GFM)\n\nVia plugins:\n\n- [subscript](https://github.com/markdown-it/markdown-it-sub)\n- [superscript](https://github.com/markdown-it/markdown-it-sup)\n- [footnote](https://github.com/markdown-it/markdown-it-footnote)\n- [definition list](https://github.com/markdown-it/markdown-it-deflist)\n- [abbreviation](https://github.com/markdown-it/markdown-it-abbr)\n- [emoji](https://github.com/markdown-it/markdown-it-emoji)\n- [custom container](https://github.com/markdown-it/markdown-it-container)\n- [insert](https://github.com/markdown-it/markdown-it-ins)\n- [mark](https://github.com/markdown-it/markdown-it-mark)\n- ... and [others](https://www.npmjs.org/browse/keyword/markdown-it-plugin)\n\n\n### Manage rules\n\nBy default all rules are enabled, but can be restricted by options. On plugin\nload all its rules are enabled automatically.\n\n```js\n// Activate/deactivate rules, with currying\nvar md = require('markdown-it')()\n            .disable([ 'link', 'image' ])\n            .enable([ 'link' ])\n            .enable('image');\n\n// Enable everything\nmd = require('markdown-it')({\n  html: true,\n  linkify: true,\n  typographer: true,\n});\n```\n\nYou can find all rules in sources:\n[parser_core.js](lib/parser_core.js), [parser_block](lib/parser_block.js),\n[parser_inline](lib/parser_inline.js).\n\n\n## Benchmark\n\nHere is the result of readme parse at MB Pro Retina 2013 (2.4 GHz):\n\n```bash\nmake benchmark-deps\nbenchmark/benchmark.js readme\n\nSelected samples: (1 of 28)\n \u003e README\n\nSample: README.md (7774 bytes)\n \u003e commonmark-reference x 1,222 ops/sec ±0.96% (97 runs sampled)\n \u003e current x 743 ops/sec ±0.84% (97 runs sampled)\n \u003e current-commonmark x 1,568 ops/sec ±0.84% (98 runs sampled)\n \u003e marked x 1,587 ops/sec ±4.31% (93 runs sampled)\n```\n\n__Note.__ CommonMark version runs with [simplified link normalizers](https://github.com/markdown-it/markdown-it/blob/master/benchmark/implementations/current-commonmark/index.js)\nfor more \"honest\" compare. Difference is ~ 1.5x.\n\nAs you can see, `markdown-it` doesn't pay with speed for it's flexibility.\nSlowdown of \"full\" version caused by additional features not available in\nother implementations.\n\n\n--\u003e\n\n## Upgrading\n\nUpgrading to `8.4.1.2` could cause some small breakage if you are using any custom plugins.  The [motion-markdown-it-plugins](https://github.com/digitalmoksha/motion-markdown-it-plugins) plugins have already been upgraded.\n\n#### charCodeAt\n\nMake sure you have\n\n```ruby\ninclude MarkdownIt::Common::Utils\n```\n\nat the top of your plugin file.  Then change any references to `charCodeAt`.  For example,\n\n```ruby\nstate.src.charCodeAt(pos)\n```\n\nwould become\n\n```ruby\ncharCodeAt(state.src, pos)\n```\n\n#### slice_to_end\n\n`slice_to_end` has been removed.  Change references like this\n\n```ruby\nstate.src.slice_to_end(pos)\n```\n\nto\n\n```ruby\nstate.src[pos..-1]\n```\n\n## References / Thanks\n\nThanks to the authors of the original implementation in Javascript, [markdown-it](https://github.com/markdown-it/markdown-it):\n\n- Alex Kocharin [github/rlidwka](https://github.com/rlidwka)\n- Vitaly Puzrin [github/puzrin](https://github.com/puzrin)\n\nand to [John MacFarlane](https://github.com/jgm) for his work on the\nCommonMark spec and reference implementations.\n\n**Related Links:**\n\n- https://github.com/jgm/CommonMark - reference CommonMark implementations in C \u0026 JS,\n  also contains latest spec \u0026 online demo.\n- http://talk.commonmark.org - CommonMark forum, good place to collaborate\n  developers' efforts.\n\n## License\n\n[MIT](https://github.com/digitalmoksha/motion-markdown-it/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalmoksha%2Fmotion-markdown-it","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitalmoksha%2Fmotion-markdown-it","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalmoksha%2Fmotion-markdown-it/lists"}