all repos — markup @ 36ec73065f706fbd073126dcccb4b837be94ef9b

The code we use to render README.your_favorite_markup

okay this is how we'll deal with broken commands
Chris Wanstrath chris@ozmm.org
Tue, 17 Nov 2009 18:36:06 -0800
commit

36ec73065f706fbd073126dcccb4b837be94ef9b

parent

d479ef1e0b051a011a0ebf549991363f6e380cb3

2 files changed, 5 insertions(+), 4 deletions(-)

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

@@ -31,10 +31,9 @@ if File.exists?(file = File.dirname(__FILE__) + "/commands/#{command}")

command = file end - return if !system("which #{command} > /dev/null") - add_markup(regexp) do |content| rendered = execute(command, content) + rendered = rendered.to_s.empty? ? content : rendered block ? block.call(rendered) : rendered end end

@@ -64,6 +63,8 @@ stdin.close

out = stdout.read end out.gsub("\r", '') + rescue Errno::EPIPE + "" end # Define markups
M test/markup_test.rbtest/markup_test.rb

@@ -30,7 +30,7 @@

def test_fails_gracefully_on_missing_commands GitHub::Markup.command(:i_made_it_up, /mde/) text = 'hi there' - assert_equal false, GitHub::Markup.can_render?('README.mde') + assert GitHub::Markup.can_render?('README.mde') actual = GitHub::Markup.render('README.mde', text) assert_equal text, actual end

@@ -38,7 +38,7 @@

def test_fails_gracefully_on_missing_env_commands GitHub::Markup.command('/usr/bin/env totally_fake', /tf/) text = 'hey mang' - assert_equal false, GitHub::Markup.can_render?('README.tf') + assert GitHub::Markup.can_render?('README.tf') actual = GitHub::Markup.render('README.tf', text) assert_equal text, actual end