Repository is archived
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Render Markdown via HTML::Pipeline in Rails.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.5
>= 0
>= 0
~> 2.14

Runtime

 Project Readme

HTML::Pipeline for Rails Build Status

Adds support for rendering views via HTML::Pipeline in Rails. GitHub Flavored Markdown in your Rails app!

Installation

Add this line to your Gemfile:

gem 'html_pipeline_rails'

and then run:

$ bundle

All views ending in .md will then be rendered as HTML, with support for ERB.

Example

app/views/layouts/application.html.erb:

<footer>
  <%= render 'shared/footer' %>
</footer>

app/views/shared/footer.md:

## Copyright <%= Time.now.year %> **BigCorp**

All rights reserved.

Cool, eh?

Customization

By default, .md views will run through ERB, and then the MarkdownFilter pipeline. Note that this means anything output from your ERB tags in a .md view will be parsed as Markdown. You can customize the render pipeline like so:

# config/initializers/html_pipeline.rb
HtmlPipelineRails.config do |c|
  c.pipeline = HTML::Pipeline.new([
    HTML::Pipeline::MarkdownFilter,
    HTML::Pipeline::MentionFilter
  ])
end

In this case, @mentions will now be converted to links. See the HTML::Pipeline documentation to learn about the different options.

For the HTML::Pipeline::EmojiFilter, follow the Rake task instructions in the gemoji gem, and set the :asset_root in your config like so:

HtmlPipelineRails.config do |c|
  context = {
    asset_root: '/images',
    # ...
  }

  c.pipeline = HTML::Pipeline.new([
    HTML::Pipeline::EmojiFilter
    # ...
  ], context)
end

Contributing

Run tests with:

bundle
# then
bundle exec rspec
# or
bundle exec guard