Add link_to_gfm helper and specs
This commit is contained in:
parent
8ce390333a
commit
6873d07f62
2 changed files with 24 additions and 0 deletions
|
@ -110,6 +110,17 @@ module ApplicationHelper
|
|||
text.html_safe
|
||||
end
|
||||
|
||||
# circumvents nesting links, which will behave bad in browsers
|
||||
def link_to_gfm(body, url, html_options = {})
|
||||
gfm_body = gfm(body, html_options)
|
||||
|
||||
gfm_body.gsub!(%r{<a.*?>.*?</a>}m) do |match|
|
||||
"</a>#{match}#{link_to("", url, html_options)[0..-5]}" # "</a>".length +1
|
||||
end
|
||||
|
||||
link_to(gfm_body.html_safe, url, html_options)
|
||||
end
|
||||
|
||||
def markdown(text)
|
||||
@__renderer ||= Redcarpet::Markdown.new(Redcarpet::Render::GitlabHTML.new(self, filter_html: true), {
|
||||
no_intra_emphasis: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue