Skip to content

Commit

Permalink
Automatically add links to images embedded in comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dmac committed Oct 9, 2011
1 parent aed404a commit 4e255de
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/string_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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", "<br/>")
end
Expand Down
3 changes: 2 additions & 1 deletion models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4e255de

Please sign in to comment.