Project

General

Profile

Actions

Defect #43

closed

problem with textilize and :hard_breaks - with solutions

Added by Pavol Murin over 17 years ago. Updated over 17 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

As described here: http://wiki.rubyonrails.org/rails/pages/RedCloth , there is a problem with :hard_breaks in textilize.
To see the problem in action (taken from the link above):

textilize("h1. This is a test of textile\n\nParagraph\n\nAnother paragraph\n\n* Bullets")

produces:

<h1>This is a test of textile<br />
Paragraph<br />
Another paragraph<br />
<ul>
<li>Bullets</li>
</ul></h1>

(note - this is all a header!!!)

There are several "fixes" proposed - the simplest ones are:

1. don't use :hard_breaks
2. add the following lines add the beginning of app\helpers\application_helper.rb

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/r
edcloth/changeset/128</a>
def hard_break( text )
text.gsub!( /(.)\n(?!\n|\Z| ([#=]+(\s|$)|[{|]))/, "\\1<br />" ) if hard_breaks
end
end

note - there are people complaining, that 2. doesn't help. It did help me, though :-)

Personally, I find 2 better.

muro

Actions

Also available in: Atom PDF