Defect #30434 » 30434-remove-cr-chars-v2.patch
lib/redmine/syntax_highlighting.rb | ||
---|---|---|
76 | 76 |
# Highlights +text+ as the content of +filename+ |
77 | 77 |
# Should not return line numbers nor outer pre tag |
78 | 78 |
def highlight_by_filename(text, filename) |
79 |
text = text.gsub(/\r\n?/, "\n") |
|
79 | 80 |
lexer =::Rouge::Lexer.guess_by_filename(filename) |
80 | 81 |
formatter = ::Rouge::Formatters::HTML.new |
81 | 82 |
::Rouge.highlight(text, lexer, CustomHTMLLinewise.new(formatter)) |
test/helpers/application_helper_test.rb | ||
---|---|---|
1123 | 1123 |
end |
1124 | 1124 |
end |
1125 | 1125 | |
1126 |
def test_syntax_highlight_should_normalize_line_endings |
|
1127 |
assert_equal "line 1\nline 2\n", syntax_highlight("test.txt", "line 1\rline 2\r\n") |
|
1128 |
end |
|
1129 | ||
1126 | 1130 |
def test_to_path_param |
1127 | 1131 |
assert_equal 'test1/test2', to_path_param('test1/test2') |
1128 | 1132 |
assert_equal 'test1/test2', to_path_param('/test1/test2/') |