From 4b831c9e65fe9f0122dcc092bcd72523728f065d Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 11 Mar 2015 17:22:23 +0800 Subject: [PATCH] =?UTF-8?q?#2001=20=E9=A1=B9=E7=9B=AE--=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E9=9B=86=E4=B8=ADwiki-=E2=80=9C=E6=9F=A5=E7=9C=8B=E5=B7=AE?= =?UTF-8?q?=E5=88=AB=E2=80=9D=E4=B8=AD=E6=9C=89html=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 11 +++++++++++ app/views/wiki/diff.html.erb | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 30b2e7a21..a36f4b183 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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+/, "

"). # 2+ newline -> 2 br + gsub(/([^\n]\n)(?=[^\n])/, '\1
'). # 1 newline -> br + gsub("&nbsp", " "). #gsub(/<\/?.*?>/,""). + gsub(/<\/?.*?>/, ""). + gsub(""", "'"). + html_safe + end + def lang_options_for_select(blank=true) { 'Chinese简体中文 '=> 'zh', :English => :en} end diff --git a/app/views/wiki/diff.html.erb b/app/views/wiki/diff.html.erb index adeaa7cab..6af69db68 100644 --- a/app/views/wiki/diff.html.erb +++ b/app/views/wiki/diff.html.erb @@ -29,5 +29,5 @@

- <%= simple_format_without_paragraph @diff.to_html %> + <%= wiki_simple_format_without_paragraph @diff.to_html %>