Project

r_mark

0.01
No commit activity in last 3 years
No release in over 3 years
Render markdown in Rails views or partials.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 4.2.0
 Project Readme

RMark

Build Status Gem Version

RMark provides that Rails application uses Markdown in views and partials.

Installation

Add this line to your application's Gemfile:

gem 'r_mark'

And then execute:

$ bundle

And also you should install Markdown parser, such as redcarpet, rdiscount, or kramdown as you like.

Usage

All one need to do is add to Gemfile and bundle. Then you can use .md view in app/views. There are two ways to render markdown.

1. Render direct

In app/views/pages/direct.md:

# Direct

- foo
- bar
- baz

2. Render via partial

In app/views/pages/partial.erb:

<%= render 'pages/partial' %>

And in app/views/pages/_partial.md:

# Partial

- foo
- bar
- baz

Customize

RMark uses redcarpet as a default Markdown parser. If you change it as you like, create config/initializers/r_mark.rb:

RMark.setup do |config|
  config.parser = :RDiscount
end

Parser supports :Redcarpet, :RDiscount, and :Kramdown.

And also you can add rendering options. Following code is an example of r_mark.rb:

RMark.setup do |config|
  # config.parser = :Redcarpet
  #
  # config.options = {
  #   autolink: true
  # }

  # config.parser = :RDiscount
  #
  # config.options = [
  #   :autolink
  # ]

  # config.parser = :Kramdown
  #
  # config.options = {
  #   auto_ids: false
  # }
end

When you add options, see also:

Contributing

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