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
<table class="filecontent syntaxhl">
<tbody>
<% 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| %>
<tr>
<th class="line-num" id="L<%= line_num %>">
<a href="#L<%= line_num %>"><%= line_num %></a>
</th>
<td class="line-code">
- <pre><%= line %></pre>
+ <pre><%= line.html_safe %></pre>
</td>
</tr>
<% line_num += 1 %>
<table class="filecontent annotate syntaxhl">
<tbody>
<% 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] %>
<tr class="bloc-<%= revision.nil? ? 0 : colors[revision.identifier || revision.revision] %>">
<th class="line-num" id="L<%= line_num %>"><a href="#L<%= line_num %>"><%= line_num %></a></th>
<td class="revision">
<%= (revision.identifier ? link_to_revision(revision, @repository) : format_revision(revision)) if revision %></td>
<td class="author"><%= h(revision.author.to_s.split('<').first) if revision %></td>
- <td class="line-code"><pre><%= line %></pre></td>
+ <td class="line-code"><pre><%= line.html_safe %></pre></td>
</tr>
<% line_num += 1 %>
<% end %>