Defect #30434 » 30434-remove-cr-chars.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.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)) |
| ... | ... | |
| 92 | 93 |
def language_supported?(language) |
| 93 | 94 |
find_lexer(language.to_s.downcase) ? true : false |
| 94 | 95 |
end |
| 95 |
|
|
| 96 | ||
| 96 | 97 |
private |
| 97 | 98 |
# Alias names used by CodeRay and not supported by Rouge |
| 98 | 99 |
LANG_ALIASES = {
|
| test/helpers/application_helper_test.rb | ||
|---|---|---|
| 1123 | 1123 |
end |
| 1124 | 1124 |
end |
| 1125 | 1125 | |
| 1126 |
def test_syntax_highlight_should_remove_cr_chars |
|
| 1127 |
assert_equal "line 1\nline 2\n", syntax_highlight(nil, "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/')
|