all repos — markup @ b29b70118618a7f1a67567fd4ba3331fc3e26331

The code we use to render README.your_favorite_markup

lib/github/markup.rb (view raw)

 1module GitHub
 2  module Markup
 3    extend self
 4    @@markups = {}
 5
 6    def markup(file, pattern, &block)
 7      require file.to_s
 8      add_markup(pattern, &block)
 9    rescue LoadError
10      nil
11    end
12
13    def add_markup(regexp, &block)
14      @@markups[regexp] = block
15    end
16
17    def renderer(filename)
18      @@markups.each do |key, value|
19        if Regexp.compile("#{key}$") =~ filename
20          return value
21        end
22      end
23    end
24
25    def render(filename, content)
26      renderer(filename)[content] || content
27    end
28
29    # Define markups
30    require 'github/markups'
31  end
32end