Merge pull request #1823 from jekyll/highlight-without-newline
This commit is contained in:
		
						commit
						122b2233b1
					
				|  | @ -41,14 +41,15 @@ eos | |||
|       end | ||||
| 
 | ||||
|       def render(context) | ||||
|         code = super.to_s.strip | ||||
|         case context.registers[:site].highlighter | ||||
|         when 'pygments' | ||||
|           render_pygments(context, super) | ||||
|           render_pygments(context, code) | ||||
|         when 'rouge' | ||||
|           render_rouge(context, super) | ||||
|           render_rouge(context, code) | ||||
|         else | ||||
|           render_codehighlighter(context, super) | ||||
|         end | ||||
|           render_codehighlighter(context, code) | ||||
|         end.strip | ||||
|       end | ||||
| 
 | ||||
|       def render_pygments(context, code) | ||||
|  | @ -106,8 +107,9 @@ eos | |||
| 
 | ||||
|       def add_code_tags(code, lang) | ||||
|         # Add nested <code> tags to code blocks | ||||
|         code = code.sub(/<pre>/,'<pre><code class="' + lang.to_s.gsub("+", "-") + '">') | ||||
|         code = code.sub(/<\/pre>/,"</code></pre>") | ||||
|         code = code.sub(/<pre>\n*/,'<pre><code class="' + lang.to_s.gsub("+", "-") + '">') | ||||
|         code = code.sub(/\n*<\/pre>/,"</code></pre>") | ||||
|         code.strip | ||||
|       end | ||||
| 
 | ||||
|     end | ||||
|  |  | |||
|  | @ -33,8 +33,12 @@ title: This is a test | |||
| 
 | ||||
| This document results in a markdown error with maruku | ||||
| 
 | ||||
| {% highlight text %}#{code}{% endhighlight %} | ||||
| {% highlight text linenos %}#{code}{% endhighlight %} | ||||
| {% highlight text %} | ||||
| #{code} | ||||
| {% endhighlight %} | ||||
| {% highlight text linenos %} | ||||
| #{code} | ||||
| {% endhighlight %} | ||||
| CONTENT | ||||
|     create_post(content, override) | ||||
|   end | ||||
|  | @ -87,11 +91,11 @@ CONTENT | |||
|     end | ||||
| 
 | ||||
|     should "render markdown with pygments" do | ||||
|       assert_match %{<pre><code class="text">test\n</code></pre>}, @result | ||||
|       assert_match %{<pre><code class="text">test</code></pre>}, @result | ||||
|     end | ||||
| 
 | ||||
|     should "render markdown with pygments with line numbers" do | ||||
|       assert_match %{<pre><code class="text"><span class="lineno">1</span> test\n</code></pre>}, @result | ||||
|       assert_match %{<pre><code class="text"><span class="lineno">1</span> test</code></pre>}, @result | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|  | @ -101,7 +105,7 @@ CONTENT | |||
|     end | ||||
| 
 | ||||
|     should "not embed the file" do | ||||
|       assert_match %{<pre><code class="text">./jekyll.gemspec\n</code></pre>}, @result | ||||
|       assert_match %{<pre><code class="text">./jekyll.gemspec</code></pre>}, @result | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|  | @ -111,7 +115,7 @@ CONTENT | |||
|     end | ||||
| 
 | ||||
|     should "render markdown with pygments line handling" do | ||||
|       assert_match %{<pre><code class="text">Æ\n</code></pre>}, @result | ||||
|       assert_match %{<pre><code class="text">Æ</code></pre>}, @result | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue