HTML::Pipeline::LinkifyGitHub
provides a HTML::Pipeline
filter to autolink GitHub urls.
Add this line to your application's Gemfile:
gem "html-pipeline-linkify_github"
And then execute:
$ bundle
Or install it yourself as:
$ gem install html-pipeline-linkify_github
Use HTML::Pipeline::LinkifyGitHubFilter
filter after your markdown filter.
require "html/pipeline"
require "html/pipeline/linkify_github"
pipeline = HTML::Pipeline.new [
HTML::Pipeline::MarkdownFilter,
HTML::Pipeline::LinkifyGitHubFilter
]
result = pipeline.call <<-MARKDOWN.strip_heredoc
https://github.com/rails/rails/pull/21862
https://github.com/rails/rails/issues/21843
https://github.com/rails/rails/commit/67597e1719ec6af7e22964603cc77aa5b085a864
MARKDOWN
puts result[:output].to_html
prints:
<p><a href="https://github.com/rails/rails/pull/21862">rails/rails#21862</a><br>
<a href="https://github.com/rails/rails/issues/21843">rails/rails#21843</a><br>
<a href="https://github.com/rails/rails/commit/67597e1719ec6af7e22964603cc77aa5b085a864">rails/rails@`67597e`</a></p>
This RubyGem requires Ruby 2.0+ because support for 1.9.3 is officially end.
Please see the CONTRIBUTING.md file.
A huge THANK YOU to all our contributors! ❤️
Please see the LICENSE.md file.
We specialise in rapid development of high quality MVPs. Hire us to turn your product idea into reality.