diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8d08e9d5b..8a4d387ad 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -355,6 +355,12 @@ module ApplicationHelper end end + def syntax_highlight_lines(name, content) + lines = [] + syntax_highlight(name, content).each_line { |line| lines << line } + lines + end + def syntax_highlight(name, content) Redmine::SyntaxHighlighting.highlight_by_filename(content, name) end diff --git a/app/views/common/_file.html.erb b/app/views/common/_file.html.erb index 418073efa..22126b949 100644 --- a/app/views/common/_file.html.erb +++ b/app/views/common/_file.html.erb @@ -2,13 +2,13 @@ <% line_num = 1 %> -<% syntax_highlight(filename, Redmine::CodesetUtil.to_utf8_by_setting(content)).each_line do |line| %> +<% syntax_highlight_lines(filename, Redmine::CodesetUtil.to_utf8_by_setting(content)).each do |line| %> <% line_num += 1 %> diff --git a/app/views/repositories/annotate.html.erb b/app/views/repositories/annotate.html.erb index 188d9215d..1cd782588 100644 --- a/app/views/repositories/annotate.html.erb +++ b/app/views/repositories/annotate.html.erb @@ -14,14 +14,14 @@
<%= line_num %> -
<%= line %>
+
<%= line.html_safe %>
<% line_num = 1 %> - <% syntax_highlight(@path, Redmine::CodesetUtil.to_utf8_by_setting(@annotate.content)).each_line do |line| %> + <% syntax_highlight_lines(@path, Redmine::CodesetUtil.to_utf8_by_setting(@annotate.content)).each do |line| %> <% revision = @annotate.revisions[line_num - 1] %> - + <% line_num += 1 %> <% end %>
<%= line_num %> <%= (revision.identifier ? link_to_revision(revision, @repository) : format_revision(revision)) if revision %> <%= h(revision.author.to_s.split('<').first) if revision %>
<%= line %>
<%= line.html_safe %>