Reputation: 751
I use Redcarpet as my backend Markdown interpreter solution.
I want all links to have a html target attribute and its value equal to '_blank', but I can't find any solution for it.
Could any one help me? Thanks.
Upvotes: 1
Views: 617
Reputation: 167
They've since introduced a new option, which you can use like so:
link_attributes: { target: '_blank' }
Upvotes: 2
Reputation: 751
Finally I write JavaScript to handle it...
I think this is the fastest way....
Upvotes: 0
Reputation: 76784
Although I don't know specifically how to do this, I would look at using a custom renderer:
#app/lib/blank_targets.rb
class BlankTargets < Redcarpet::Render::HTML
def link(link, title, content)
#custom code here
end
end
#Your Controller
markdown = Redcarpet::Markdown.new(BlankTargets)
Upvotes: 2