diff --git a/lib/string_filter.rb b/lib/string_filter.rb index de74aa89..24895090 100644 --- a/lib/string_filter.rb +++ b/lib/string_filter.rb @@ -8,7 +8,6 @@ # # Possible extensions: # * Convert APP-XXX to jira links -# * Convert an image link (![alt][link] syntax) to a be a link to the image as well # * Make @username link to profile pages module StringFilter @@ -31,6 +30,12 @@ def link_github_issue(github_username, github_repo) end end + # Converts an embedded image (![alt][link]) to also include + # a link to the same image + def link_embedded_images + self.gsub(/!\[.*\]\((.*)\)/) { |match| "[#{match}](#{$1})" } + end + def newlines_to_html self.gsub("\n", "
") end diff --git a/models/comment.rb b/models/comment.rb index 1ad669bb..07c7be08 100644 --- a/models/comment.rb +++ b/models/comment.rb @@ -18,7 +18,8 @@ def general_comment?() commit_file_id.nil? end def file_comment?() !commit_file_id.nil? end def format - text.markdown + text.link_embedded_images + .markdown .replace_shas_with_links(commit.git_repo.name) end end