An HTML::Pipeline filter for hashtags.
Add this line to your application's Gemfile:
gem 'html-pipeline-hashtag'
And then execute:
$ bundle
Or install it yourself as:
$ gem install html-pipeline-hashtag
Example:
require 'html/pipeline'
require 'html/pipeline/hashtag/hashtag_filter'
filters = [
HTML::Pipeline::MarkdownFilter,
HTML::Pipeline::HashtagFilter
]
pipeline = HTML::Pipeline.new filters
input = "Hello #world!"
context = {
:tag_url => '/tags/%{tag}'
}
result = pipeline.call(input, context)
puts result[:output].to_html
# => "<p>Hello <a href=\"/tags/world\" target=\"_blank\" class=\"hashtag\">#world</a>!</p>\n"
puts result[:hashtags]
# => ["world"]
Bug reports and pull requests are welcome on GitHub at https://github.com/mr-dxdy/html-pipeline-hashtag.