Merge pull request #192 from github/litcoffee Literate CoffeeScript should be rendered as Markdown
Coby Chapple coby@github.com
Thu, 12 Sep 2013 09:14:06 -0700
4 files changed,
130 insertions(+),
4 deletions(-)
M
lib/github/markups.rb
→
lib/github/markups.rb
@@ -1,17 +1,17 @@
-MD_FILES = /md|mkdn?|mdwn|mdown|markdown/ +MD_FILES = /md|mkdn?|mdwn|mdown|markdown|litcoffee/ if markup('github/markdown', MD_FILES) do |content| GitHub::Markdown.render(content) end elsif markup(:redcarpet, MD_FILES) do |content| RedcarpetCompat.new(content).to_html - end + end elsif markup(:rdiscount, MD_FILES) do |content| RDiscount.new(content).to_html - end + end elsif markup(:maruku, MD_FILES) do |content| Maruku.new(content).to_html - end + end elsif markup(:kramdown, MD_FILES) do |content| Kramdown::Document.new(content).to_html end
M
test/markup_test.rb
→
test/markup_test.rb
@@ -36,6 +36,7 @@ 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 false, GitHub::Markup.can_render?('README.cmd') + assert_equal true, GitHub::Markup.can_render?('README.litcoffee') end def test_fails_gracefully_on_missing_commands
A
test/markups/README.litcoffee
@@ -0,0 +1,59 @@
+Literate CoffeeScript Test +-------------------------- + +> Taken from https://github.com/jashkenas/coffee-script/blob/master/test/literate.litcoffee + +comment comment + + test "basic literate CoffeeScript parsing", -> + ok yes + +now with a... + + test "broken up indentation", -> + +... broken up ... + + do -> + +... nested block. + + ok yes + +Code must be separated from text by a blank line. + + test "code blocks must be preceded by a blank line", -> + +The next line is part of the text and will not be executed. + fail() + + ok yes + +Code in `backticks is not parsed` and... + + test "comments in indented blocks work", -> + do -> + do -> + # Regular comment. + + ### + Block comment. + ### + + ok yes + +Regular [Markdown](http://example.com/markdown) features, +like links and unordered lists, are fine: + + * I + + * Am + + * A + + * List + +Tabs work too: + + test "tabbed code", -> + ok yes
A
test/markups/README.litcoffee.html
@@ -0,0 +1,66 @@
+<h2>Literate CoffeeScript Test</h2> + +<blockquote> +<p>Taken from https://github.com/jashkenas/coffee-script/blob/master/test/literate.litcoffee</p> +</blockquote> + +<p>comment comment</p> + +<pre><code>test "basic literate CoffeeScript parsing", -> + ok yes +</code></pre> + +<p>now with a...</p> + +<pre><code>test "broken up indentation", -> +</code></pre> + +<p>... broken up ...</p> + +<pre><code> do -> +</code></pre> + +<p>... nested block.</p> + +<pre><code> ok yes +</code></pre> + +<p>Code must be separated from text by a blank line.</p> + +<pre><code>test "code blocks must be preceded by a blank line", -> +</code></pre> + +<p>The next line is part of the text and will not be executed. + fail()</p> + +<pre><code> ok yes +</code></pre> + +<p>Code in <code>backticks is not parsed</code> and...</p> + +<pre><code>test "comments in indented blocks work", -> + do -> + do -> + # Regular comment. + + ### + Block comment. + ### + + ok yes +</code></pre> + +<p>Regular <a href="http://example.com/markdown">Markdown</a> features, +like links and unordered lists, are fine:</p> + +<ul> +<li><p>I</p></li> +<li><p>Am</p></li> +<li><p>A</p></li> +<li><p>List</p></li> +</ul> + +<p>Tabs work too:</p> + +<p>test "tabbed code", -> + ok yes</p>