Merge pull request #35 from github/pygments-new-lines

Preserve new lines for syntax highlighting
This commit is contained in:
Joshua Peek
2011-07-05 14:47:03 -07:00
2 changed files with 11 additions and 1 deletions

View File

@@ -141,7 +141,7 @@ module Linguist
#
# Returns html String
def colorize(text)
Albino.colorize(text, self)
Albino.new(text, self).colorize(:O => 'stripnl=false')
end
# Public: Highlight syntax of text without the outer highlight div

View File

@@ -459,6 +459,16 @@ Hello
assert_equal <<-HTML, Language['Ruby'].colorize_without_wrapper("def foo\n 'foo'\nend\n")
<span class="k">def</span> <span class="nf">foo</span>
<span class="s1">&#39;foo&#39;</span>
<span class="k">end</span>
HTML
end
def test_colorize_doesnt_strip_newlines
assert_equal <<-HTML, Language['Ruby'].colorize_without_wrapper("\n\n# Foo\ndef 'foo'\nend\n")
<span class="c1"># Foo</span>
<span class="k">def</span> <span class="s1">&#39;foo&#39;</span>
<span class="k">end</span>
HTML
end