Skip to content

Commit

Permalink
auto link support, ala markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
sr committed Oct 3, 2008
1 parent 9c2e1ee commit 43f9bcf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions git-wiki.rb
Expand Up @@ -20,7 +20,11 @@ def to_html
RedCloth.new(self).to_html
end

def linkify
def auto_link
self.gsub(/<((https?|ftp|irc):[^'">\s]+)>/xi, %Q{<a href="\\1">\\1</a>})
end

def wiki_link
self.gsub(/([A-Z][a-z]+[A-Z][A-Za-z0-9]+)/) do |page|
%Q{<a class="#{Page.css_class_for(page)}" href="/#{page}">#{page.titleize}</a>}
end
Expand Down Expand Up @@ -86,7 +90,7 @@ def initialize(blob)
end

def to_html
content.linkify.to_html
content.auto_link.wiki_link.to_html
end

def to_s
Expand Down

0 comments on commit 43f9bcf

Please sign in to comment.