all repos — markup @ 5469fb357ee49696aa2035c3d91fc2bbd6f9c26d

The code we use to render README.your_favorite_markup

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
commit

5469fb357ee49696aa2035c3d91fc2bbd6f9c26d

parent

54086264516d08eddf43684b3da589f07a969dcf

M lib/github/markups.rblib/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.rbtest/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 &quot;basic literate CoffeeScript parsing&quot;, -> + ok yes +</code></pre> + +<p>now with a...</p> + +<pre><code>test &quot;broken up indentation&quot;, -> +</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 &quot;code blocks must be preceded by a blank line&quot;, -> +</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 &quot;comments in indented blocks work&quot;, -> + 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 &quot;tabbed code&quot;, -> + ok yes</p>