all repos — markup @ v1.0.0

The code we use to render README.your_favorite_markup

lib/github/markup/implementation.rb (view raw)

 1module GitHub
 2  module Markup
 3    class Implementation
 4      attr_reader :regexp
 5
 6      def initialize(regexp)
 7        @regexp = regexp
 8      end
 9
10      def load
11        # no-op by default
12      end
13
14      def render(content)
15        raise NotImplementedError, "subclasses of GitHub::Markup::Implementation must define #render"
16      end
17
18      def match?(filename)
19        file_ext_regexp =~ filename
20      end
21
22    private
23      def file_ext_regexp
24        @file_ext_regexp ||= /\.(#{regexp})\z/
25      end
26    end
27  end
28end