all repos — markup @ 768130a25a0fb9ed979887ad039b796237397f99

The code we use to render README.your_favorite_markup

nicer dsl
Chris Wanstrath chris@ozmm.org
Fri, 30 Oct 2009 18:55:46 -0700
commit

768130a25a0fb9ed979887ad039b796237397f99

parent

c70c6fad0c85e90f5de9982ba75cc03fc139ba1d

1 files changed, 14 insertions(+), 16 deletions(-)

jump to
M lib/github/markup.rblib/github/markup.rb

@@ -3,6 +3,13 @@ module Markup

extend self @@markups = {} + def markup(file, pattern, &block) + require file.to_s + add_markup(pattern, &block) + rescue LoadError + nil + end + def add_markup(regexp, &block) @@markups[regexp] = block end

@@ -18,23 +25,14 @@

def render(filename, content) renderer(filename)[content] || content end - end -end -begin - require 'rdiscount' - GitHub::Markup.add_markup(/md|mkdn?|markdown/) do |content| - Markdown.new(content).to_html - end -rescue LoadError - nil -end + # Markup definitions + markup(:markdown, /md|mkdn?|markdown/) do |content| + Markdown.new(content).to_html + end -begin - require 'redcloth' - GitHub::Markup.add_markup(/textile/) do |content| - RedCloth.new(content).to_html + markup(:redcloth, /textile/) do |content| + RedCloth.new(content).to_html + end end -rescue LoadError - nil end