Sha256: 29f19b8887e98d8fb1e8b6d152ce500d0bb5380e9ac2f779df0750b751d86f1d

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

# Mongoid Markdown Extension

[![Build Status](https://travis-ci.org/tomasc/mongoid_markdown_extension.svg)](https://travis-ci.org/tomasc/mongoid_markdown_extension) [![Coverage Status](https://img.shields.io/coveralls/tomasc/mongoid_markdown_extension.svg)](https://coveralls.io/r/tomasc/mongoid_markdown_extension)

[Mongoid](https://github.com/mongoid/mongoid) field extension that returns an object with `to_html` method returning the content converted from Markdown syntax to html. The Markdown conversion is done using the [Redcarpet](https://github.com/vmg/redcarpet) library.

## Installation

Add this line to your application's Gemfile:

    gem 'mongoid_markdown_extension'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install mongoid_markdown_extension

## Configuration

The defaults are as follows:

```Ruby
extensions = {
    autolink: true
    footnotes: true
    highlight: true
    space_after_headers: true
    strikethrough: true
    superscript: true
}

render_options = {}
```

These can be overwritten with an initializer, for example `config/initializers/mongoid_markdown.rb`:

```Ruby
MongoidMarkdownExtension::Markdown.configure do |c|
    c.extensions = { autolink: true }
    c.render_options = { filter_html: true }
end
```

See [Redcarpet documentation](https://github.com/vmg/redcarpet) for available extensions and render options.

## Usage

Add to a Mongoid model:

    class MyModel
        include Mongoid::Document
        field :text, type: MongoidMarkdownExtension::Markdown
    end
    
Use it in a view:

    = my_model.text.to_html

## Contributing

1. Fork it ( https://github.com/tomasc/mongoid_markdown_extension/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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid_markdown_extension-0.0.1 README.md