Skip to content

zenizh/r_mark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Render markdown in Rails views or partials.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages