RMark
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
- Fork it ( https://github.com/kami30k/r_mark/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request