#2001 项目--工具集中wiki-“查看差别”中有html标签

This commit is contained in:
sw 2015-03-11 17:22:23 +08:00
parent 04e5aee3c2
commit 4b831c9e65
2 changed files with 12 additions and 1 deletions

View File

@ -1198,6 +1198,17 @@ module ApplicationHelper
html_safe
end
def wiki_simple_format_without_paragraph(text)
text.to_s.
gsub(/\r\n?/, "\n"). # \r\n and \r -> \n
gsub(/\n\n+/, "<br /><br />"). # 2+ newline -> 2 br
gsub(/([^\n]\n)(?=[^\n])/, '\1<br />'). # 1 newline -> br
gsub("&amp;nbsp", " "). #gsub(/<\/?.*?>/,"").
gsub(/&lt;\/?.*?&gt;/, "").
gsub("&quot;", "'").
html_safe
end
def lang_options_for_select(blank=true)
{ 'Chinese简体中文 '=> 'zh', :English => :en}
end

View File

@ -29,5 +29,5 @@
</p>
<div class="text-diff" style="word-break: break-all;word-wrap: break-word;">
<%= simple_format_without_paragraph @diff.to_html %>
<%= wiki_simple_format_without_paragraph @diff.to_html %>
</div>