Rouge gem 没有在格式化代码中显示换行符?

Rouge gem not showing line breaks in formatted code?

我使用 rouge gem here (i.e. the documentation), as well as and 遵循了最少的示例。

一切正常,只是代码中没有出现换行符。

明确地说,代码如下

def plus_two(x)
  x + 2
end

颜色正确突出显示,但呈现在一行中,就像这样

def plus_two(x) x + 2 end 

我怎样才能让它呈现 换行符(就像在代码文件中一样)

改变

require 'rouge'
source = "def plus_two(x)\n  x + 2\nend"
formatter = Rouge::Formatters::HTML.new
lexer = Rouge::Lexers::R.new
@code = formatter.format(lexer.lex(source)) 

require 'rouge'
source = "def plus_two(x)\n  x + 2\nend"
formatter = Rouge::Formatters::HTML.new
formatter = Rouge::Formatters::HTMLLinewise.new(formatter, class: 'line-%i')
lexer = Rouge::Lexers::R.new
@code = formatter.format(lexer.lex(source))  

更多格式选项here