Add data-turbo-frame attribute to links in comments
This commit is contained in:
@@ -36,9 +36,28 @@ class MarkdownRenderer < Redcarpet::Render::HTML
|
||||
block_code(code, language) # call Rouge Redcarpet plugin
|
||||
end
|
||||
|
||||
def link(url, title, content)
|
||||
attributes = { href: url }
|
||||
attributes[:title] = title if title
|
||||
attributes["data-turbo-frame"] = "_top"
|
||||
|
||||
"<a #{html_attributes(attributes)}>#{content}</a>"
|
||||
end
|
||||
|
||||
def autolink(url, link_type)
|
||||
attributes = { href: url }
|
||||
attributes["data-turbo-frame"] = "_top"
|
||||
|
||||
"<a #{html_attributes(attributes)}>#{url}</a>"
|
||||
end
|
||||
|
||||
private
|
||||
attr_reader :id_counts
|
||||
|
||||
def html_attributes(attributes)
|
||||
attributes.map { |key, value| %Q(#{key}="#{value}") }.join(" ")
|
||||
end
|
||||
|
||||
def unique_id(text)
|
||||
text.parameterize.then do |base_id|
|
||||
id_counts[base_id] += 1
|
||||
|
||||
Reference in New Issue
Block a user