Has anybody gotten :hard_breaks to work with RedCloth? I''m doing: self.body_html = RedCloth.new(self.body).to_html(:textile) which works, except that it doesn''t transform hard breaks to <br /> tags, which is really important for me. However, if I do: self.body_html = RedCloth.new(self.body, [ :hard_breaks ]).to_html(:textile) then it converts ALL breaks into <br /> tags, including what should be paragraph breaks, which get transformed into two consecutive <br /> tags. Anybody know a workaround for this? Thanks! Ryan
I''m not sure I understand the problem. What do you expect it to do with paragraph breaks? On 1/26/06, Ryan Heneise <ryenski@gmail.com> wrote:> > Has anybody gotten :hard_breaks to work with RedCloth? > > I''m doing: > > self.body_html = RedCloth.new(self.body).to_html(:textile) > > which works, except that it doesn''t transform hard breaks to <br /> > tags, which is really important for me. > > However, if I do: > > self.body_html = RedCloth.new(self.body, [ :hard_breaks > ]).to_html(:textile) > > then it converts ALL breaks into <br /> tags, including what should be > paragraph breaks, which get transformed into two consecutive <br /> > tags. > > Anybody know a workaround for this? > > Thanks! > Ryan > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060127/0e36daf9/attachment-0001.html
On 1/27/06, Paul Barry <mail@paulbarry.com> wrote:> I''m not sure I understand the problem. What do you expect it to do with > paragraph breaks? >Ok, well let me go to Why''s Textile Reference (http://www.hobix.com/textile/). Under the heading "LINE BREAKS" it says "Line breaks are converted to HTML breaks." So the text: I spoke. And none replied. would be converted to <p>I spoke. And none replied.</p> What I want is to insert a <br /> tag instead of an HTML break. So my desired output would look like this: <p>I spoke. <br /> And none replied.</p> Any idea how I can do this? Thanks!> > On 1/26/06, Ryan Heneise < ryenski@gmail.com> wrote: > > > > Has anybody gotten :hard_breaks to work with RedCloth? > > > > I''m doing: > > > > self.body_html = RedCloth.new(self.body).to_html(:textile) > > > > which works, except that it doesn''t transform hard breaks to <br /> > > tags, which is really important for me. > > > > However, if I do: > > > > self.body_html = RedCloth.new(self.body, [ :hard_breaks > ]).to_html(:textile) > > > > then it converts ALL breaks into <br /> tags, including what should be > > paragraph breaks, which get transformed into two consecutive <br /> > > tags. > > > > Anybody know a workaround for this? > > > > Thanks! > > Ryan
irb(main):001:0> require ''RedCloth'' => true irb(main):002:0> RedCloth.new("hello\nworld",[ :hard_breaks ]).to_html(:textile).to_s => "<p>hello<br />world</p>" On 1/27/06, Ryan Heneise <ryenski@gmail.com> wrote:> > On 1/27/06, Paul Barry <mail@paulbarry.com> wrote: > > I''m not sure I understand the problem. What do you expect it to do with > > paragraph breaks? > > > > Ok, well let me go to Why''s Textile Reference ( > http://www.hobix.com/textile/). > > Under the heading "LINE BREAKS" it says "Line breaks are converted to > HTML breaks." > > So the text: > > I spoke. > And none replied. > > would be converted to > > <p>I spoke. > And none replied.</p> > > What I want is to insert a <br /> tag instead of an HTML break. So my > desired output would look like this: > > <p>I spoke. <br /> > And none replied.</p> > > Any idea how I can do this? > > > Thanks! > > > > > > On 1/26/06, Ryan Heneise < ryenski@gmail.com> wrote: > > > > > > Has anybody gotten :hard_breaks to work with RedCloth? > > > > > > I''m doing: > > > > > > self.body_html = RedCloth.new(self.body).to_html(:textile) > > > > > > which works, except that it doesn''t transform hard breaks to <br /> > > > tags, which is really important for me. > > > > > > However, if I do: > > > > > > self.body_html = RedCloth.new(self.body, [ :hard_breaks > > ]).to_html(:textile) > > > > > > then it converts ALL breaks into <br /> tags, including what should be > > > paragraph breaks, which get transformed into two consecutive <br /> > > > tags. > > > > > > Anybody know a workaround for this? > > > > > > Thanks! > > > Ryan > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060127/965a8885/attachment.html
Paul Barry wrote:> irb(main):001:0> require ''RedCloth'' > => true > irb(main):002:0> RedCloth.new("hello\nworld",[ :hard_breaks > ]).to_html(:textile).to_s > => "<p>hello<br />world</p>"I think the issue is this: irb(main):002:0> RedCloth.new("hello\n\n\nworld\nhello\nagain", [:hard_breaks]). to_html(:textile).to_s => "<p>hello<br />\nworld<br />hello<br />again</p>" irb(main):003:0> RedCloth.new("hello\n\n\nworld\nhello\nagain").to_html(:textile ).to_s => "<p>hello</p>\n\n\n\t<p>world\nhello\nagain</p>" irb(main):004:0> IE at the moment this: hello world hello again goes to either <p>hello<br /> world<br /> hello<br /> again</p> or: <p>hello</p> <p>world hello again</p> What we really would like is this: <p>hello</p> <p>world<br/> hello<br /> again</p> IE 2+ breaks = paragraph, 1 break = br -- R.Livsey http://livsey.org
On 1/27/06, Richard Livsey <richard@livsey.org> wrote:> What we really would like is this: > > <p>hello</p> > <p>world<br/> > hello<br /> > again</p> > > IE 2+ breaks = paragraph, 1 break = br >Yes! Richard you nailed it. I''ve been experimenting with using a custom block (as Why described on http://redhanded.hobix.com/inspect/usingRedcloth3.html), without much success. Something like: text = "My first paragraph and second line. My second paragraph and second line. My third paragraph." class CustomRedCloth < RedCloth def textile_code( tag, atts, cite, content ) content.gsub(/\n/, "<br />") end end t1 = CustomRedCloth.new(text).to_html
On Thu, 26 Jan 2006 16:03:32 -0800, Ryan Heneise wrote:> However, if I do: > > self.body_html = RedCloth.new(self.body, [ :hard_breaks ]).to_html(:textile) > > then it converts ALL breaks into <br /> tags, including what should be > paragraph breaks, which get transformed into two consecutive <br /> > tags.You''re not using RedCloth 3.0.4, are you? That''s horribly broken, and I seem to remember running into exactly that bug with it... someone was refactoring it but I haven''t heard any updates lately, and so the solution is to fall back to 3.0.3.
Jay Levitt wrote:> On Thu, 26 Jan 2006 16:03:32 -0800, Ryan Heneise wrote: > >> However, if I do: >> >> self.body_html = RedCloth.new(self.body, [ :hard_breaks ]).to_html(:textile) >> >> then it converts ALL breaks into <br /> tags, including what should be >> paragraph breaks, which get transformed into two consecutive <br /> >> tags. > > You''re not using RedCloth 3.0.4, are you? That''s horribly broken, and I > seem to remember running into exactly that bug with it... someone was > refactoring it but I haven''t heard any updates lately, and so the solution > is to fall back to 3.0.3. >I was using 3.0.4 yes and can confirm that falling back to 3.0.3 gets me what I want. Thanks for that! -- R.Livsey http://livsey.org
Falling back to RedCloth 3.0.3 worked for me as well. Thanks Jay! On 1/28/06, Richard Livsey <richard@livsey.org> wrote:> Jay Levitt wrote: > > > > You''re not using RedCloth 3.0.4, are you? That''s horribly broken, and I > > seem to remember running into exactly that bug with it... someone was > > refactoring it but I haven''t heard any updates lately, and so the solution > > is to fall back to 3.0.3. > > > > I was using 3.0.4 yes and can confirm that falling back to 3.0.3 gets me > what I want. > > Thanks for that!
My host, Dreamhost, has both 3.0.3 and 3.0.4 installed. How can I preferentially load 3.0.3? I tried appending: require_gem ''RedCloth'', ''!= 3.0.4'' to the end of my config/environment.rb, and killing Rails: killall -9 dispatch.fcgi (Yes, FastCGI was working before this.) But I get this warning: Application error Rails application failed to start properly I''ve also tried this line instead: require_gem ''RedCloth'', ''!= 3.0.4'' No avail. Any insights? -B... -- Posted via http://www.ruby-forum.com/.