diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-04-22 10:10:56 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-04-22 10:10:56 +0000 |
commit | 32de29ea35c1b3e83faecee4ec49eb36bacb805f (patch) | |
tree | acec660d2837cc1b3a390b2949ec64a20d57b227 /app/helpers | |
parent | 8d7de50ca8f7b440cb67c8161122d20909a3a93f (diff) | |
download | redmine-32de29ea35c1b3e83faecee4ec49eb36bacb805f.tar.gz redmine-32de29ea35c1b3e83faecee4ec49eb36bacb805f.zip |
Fixed 10061 problem with textilize and :hard_breaks (Pavol Murin)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@464 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/application_helper.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3e078475d..47dbadfb7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -15,6 +15,14 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +class RedCloth + # Patch for RedCloth. Fixed in RedCloth r128 but _why hasn't released it yet. + # <a href="http://code.whytheluckystiff.net/redcloth/changeset/128">http://code.whytheluckystiff.net/redcloth/changeset/128</a> + def hard_break( text ) + text.gsub!( /(.)\n(?!\n|\Z| *([#*=]+(\s|$)|[{|]))/, "\\1<br />" ) if hard_breaks + end +end + module ApplicationHelper # Return current logged in user or nil @@ -139,7 +147,7 @@ module ApplicationHelper # finally textilize text @do_textilize ||= (Setting.text_formatting == 'textile') && (ActionView::Helpers::TextHelper.method_defined? "textilize") - text = @do_textilize ? auto_link(RedCloth.new(text).to_html) : simple_format(auto_link(h(text))) + text = @do_textilize ? auto_link(RedCloth.new(text, [:hard_breaks]).to_html) : simple_format(auto_link(h(text))) end def error_messages_for(object_name, options = {}) |