all repos — markup @ ddaffd382a5bc9782ca36557f70c72b9179e4c1c

The code we use to render README.your_favorite_markup

Burn `require 'markdown'` with the fire of a thousand suns

GitHub::Markup now has an actual preference order for Markdown libraries,
tries to require them explicitly and use their actual APIs instead of
the compatibility 'Markdown' layer.

Redcarpet is the default library, and the one listed in the Gemfile.
If it's not available, the (opinionated) require order is:

	- Redcarpet
	- RDiscount
	- Maruku
	- Kramdown
	- BlueCloth

This soothes my soul.
Vicent Marti tanoku@gmail.com
Wed, 07 Dec 2011 13:19:50 +0100
commit

ddaffd382a5bc9782ca36557f70c72b9179e4c1c

parent

92fb3cd0a4b44875d97ec095aa88279c0d21cec3

3 files changed, 20 insertions(+), 3 deletions(-)

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

@@ -22,8 +22,9 @@

def markup(file, pattern, &block) require file.to_s add_markup(pattern, &block) + true rescue LoadError - nil + false end def command(command, regexp, &block)
M lib/github/markup/rdoc.rblib/github/markup/rdoc.rb

@@ -1,3 +1,4 @@

+require "rdoc" require "rdoc/markup/to_html" module GitHub
M lib/github/markups.rblib/github/markups.rb

@@ -1,5 +1,20 @@

-markup(:markdown, /md|mkdn?|mdown|markdown/) do |content| - Markdown.new(content).to_html +MD_FILES = /md|mkdn?|mdown|markdown/ + +if markup(:redcarpet, MD_FILES) do |content| + RedcarpetCompat.new(content).to_html + end +elsif markup(:rdiscount, MD_FILES) do |content| + RDiscount.new(content).to_html + end +elsif markup(:maruku, MD_FILES) do |content| + Maruku.new(content).to_html + end +elsif markup(:kramdown, MD_FILES) do |content| + Kramdown::Document.new(content).to_html + end +elsif markup(:bluecloth, MD_FILES) do |content| + BlueCloth.new(content).to_html + end end markup(:redcloth, /textile/) do |content|