8784: Fix test for latest firefox.
[arvados.git] / apps / workbench / config / initializers / redcloth.rb
1 module RedClothArvadosLinkExtension
2
3   class RedClothViewBase < ActionView::Base
4     include ApplicationHelper
5     include ActionView::Helpers::UrlHelper
6     include Rails.application.routes.url_helpers
7
8     def helper_link_to_if_arvados_object(link, opts)
9       link_to_if_arvados_object(link, opts)
10     end
11   end
12
13   def refs_arvados(text)
14     text.gsub!(/"(?!\s)([^"]*\S)":(\S+)/) do
15       text, link = $~[1..2]
16       arvados_link = RedClothViewBase.new.helper_link_to_if_arvados_object(link, { :link_text => text })
17       # if it's not an arvados_link the helper will return the link unprocessed and so we will reconstruct the textile link string so it can be processed normally
18       (arvados_link == link) ? "\"#{text}\":#{link}" : arvados_link
19     end
20   end
21 end
22
23 RedCloth.send(:include, RedClothArvadosLinkExtension)