Skip to content

Commit

Permalink
Fix errors
Browse files Browse the repository at this point in the history
can_render? takes the content as argument
Literate CoffeeScript files are rendered as Markdown
  • Loading branch information
pchaigno committed Dec 20, 2015
1 parent 7828272 commit 6257172
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions lib/github/markup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def command(command, regexp, name, &block)
markups << CommandImplementation.new(regexp, command, name, &block)
end

def can_render?(filename)
!!renderer(filename)
def can_render?(filename, content)
!!renderer(filename, content)
end

def renderer(filename, content)
Expand Down
2 changes: 1 addition & 1 deletion lib/github/markup/markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Markdown < Implementation
}

def initialize
super([Linguist::Language["Markdown"], Linguist::Language["RMarkdown"]])
super([Linguist::Language["Markdown"], Linguist::Language["RMarkdown"], Linguist::Language["Literate CoffeeScript"]])
end

def load
Expand Down
36 changes: 18 additions & 18 deletions test/markup_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,31 +77,31 @@ def call
end

def test_knows_what_it_can_and_cannot_render
assert_equal false, GitHub::Markup.can_render?('README.html')
assert_equal true, GitHub::Markup.can_render?('README.markdown')
assert_equal true, GitHub::Markup.can_render?('README.rmd')
assert_equal true, GitHub::Markup.can_render?('README.Rmd')
assert_equal false, GitHub::Markup.can_render?('README.cmd')
assert_equal true, GitHub::Markup.can_render?('README.litcoffee')
assert_equal false, GitHub::Markup.can_render?('README.html', '<h1>Title</h1>')
assert_equal true, GitHub::Markup.can_render?('README.markdown', '=== Title')
assert_equal true, GitHub::Markup.can_render?('README.rmd', '=== Title')
assert_equal true, GitHub::Markup.can_render?('README.Rmd', '=== Title')
assert_equal false, GitHub::Markup.can_render?('README.cmd', 'echo 1')
assert_equal true, GitHub::Markup.can_render?('README.litcoffee', 'Title')
end

def test_each_render_has_a_name
assert_equal "markdown", GitHub::Markup.renderer('README.md').name
assert_equal "redcloth", GitHub::Markup.renderer('README.textile').name
assert_equal "rdoc", GitHub::Markup.renderer('README.rdoc').name
assert_equal "org-ruby", GitHub::Markup.renderer('README.org').name
assert_equal "creole", GitHub::Markup.renderer('README.creole').name
assert_equal "wikicloth", GitHub::Markup.renderer('README.wiki').name
assert_equal "asciidoctor", GitHub::Markup.renderer('README.adoc').name
assert_equal "restructuredtext", GitHub::Markup.renderer('README.rst').name
assert_equal "pod", GitHub::Markup.renderer('README.pod').name
assert_equal "markdown", GitHub::Markup.renderer('README.md', '=== Title').name
assert_equal "redcloth", GitHub::Markup.renderer('README.textile', '* One').name
assert_equal "rdoc", GitHub::Markup.renderer('README.rdoc', '* One').name
assert_equal "org-ruby", GitHub::Markup.renderer('README.org', '* Title').name
assert_equal "creole", GitHub::Markup.renderer('README.creole', '= Title =').name
assert_equal "wikicloth", GitHub::Markup.renderer('README.wiki', '<h1>Title</h1>').name
assert_equal "asciidoctor", GitHub::Markup.renderer('README.adoc', '== Title').name
assert_equal "restructuredtext", GitHub::Markup.renderer('README.rst', 'Title').name
assert_equal "pod", GitHub::Markup.renderer('README.pod', '=begin html').name
end

def test_raises_error_if_command_exits_non_zero
GitHub::Markup.command('test/fixtures/fail.sh', [], 'fail')
assert GitHub::Markup.can_render?('README.fail')
GitHub::Markup.command('test/fixtures/fail.sh', [Linguist::Language['Java']], 'fail')
assert GitHub::Markup.can_render?('README.java', 'stop swallowing errors')
begin
GitHub::Markup.render('README.fail', "stop swallowing errors")
GitHub::Markup.render('README.java', "stop swallowing errors")
rescue GitHub::Markup::CommandError => e
assert_equal "failure message", e.message
else
Expand Down

0 comments on commit 6257172

Please sign in to comment.