summaryrefslogtreecommitdiffstats
path: root/lib/redmine/syntax_highlighting.rb
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2019-02-03 23:24:16 +0000
committerGo MAEDA <maeda@farend.jp>2019-02-03 23:24:16 +0000
commit0997aa22b57c6af4921e5d9289d80772e6d793c4 (patch)
treec42217a5650cc1753749cd627f2cba68ee0bff15 /lib/redmine/syntax_highlighting.rb
parent40c3d045c04bb783da871c9bd8a0442308d229d7 (diff)
downloadredmine-0997aa22b57c6af4921e5d9289d80772e6d793c4.tar.gz
redmine-0997aa22b57c6af4921e5d9289d80772e6d793c4.zip
Merged r17847 from trunk to 4.0-stable (#30434).
git-svn-id: http://svn.redmine.org/redmine/branches/4.0-stable@17848 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/syntax_highlighting.rb')
-rw-r--r--lib/redmine/syntax_highlighting.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/redmine/syntax_highlighting.rb b/lib/redmine/syntax_highlighting.rb
index e2d47f277..53ae4b5ff 100644
--- a/lib/redmine/syntax_highlighting.rb
+++ b/lib/redmine/syntax_highlighting.rb
@@ -76,6 +76,13 @@ module Redmine
# Highlights +text+ as the content of +filename+
# Should not return line numbers nor outer pre tag
def highlight_by_filename(text, filename)
+ # TODO: Delete the following workaround for #30434 and
+ # test_syntax_highlight_should_normalize_line_endings in
+ # application_helper_test.rb when Rouge is improved to
+ # handle CRLF properly.
+ # See also: https://github.com/jneen/rouge/pull/1078
+ text = text.gsub(/\r\n?/, "\n")
+
lexer =::Rouge::Lexer.guess_by_filename(filename)
formatter = ::Rouge::Formatters::HTML.new
::Rouge.highlight(text, lexer, CustomHTMLLinewise.new(formatter))