CommonMarker

Crystal CI GitHub release License

Crystal wrapper for cmark-gfm, GitHub's fork of the reference parser for CommonMark.

This binding is statically linked with a specific version of cmark-gfm.

cmark-gfm supports simple parsing and rendering of markdown content.

If you want more features please check cr-cmark-gfm.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      common_marker:
        github: mamantoha/crystal-cmark-gfm
  2. Run shards install

Usage

require "common_marker"

text = File.read("README.md")
extensions = ["table", "strikethrough", "autolink", "tagfilter", "tasklist"]
options = ["unsafe"]
md = CommonMarker.new(text, options: options, extensions: extensions)
html = md.to_html

Extensions

CommonMarker initializer takes an optional third argument defining the extensions you want enabled as your CommonMark document is being processed. The documentation for these extensions are defined in this spec.

The available extensions are:

Development

cd ext && make && cd ..
crystal ./lib/crystal_lib/src/main.cr src/lib_cmark.cr.in > ./src/lib_cmark.cr

Contributing

  1. Fork it (https://github.com/mamantoha/crystal-cmark-gfm/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors