Hi, I''m having some problems with redcloth(3.0.4 gem) and textilize. I have a string: "h2. hello _what''s up?_" which is being textilized as: <h2>hello<br /> <em>what’s up?</em></h2> so no paragraph and h2 wrapped all the way. the input is coming from firefox 1.5.2 on a mac Anybody got any idea what the problem might be? -- I do things for love or money
dorian mcfarland wrote:> Hi, I''m having some problems with redcloth(3.0.4 gem) and textilize. > > I have a string: > "h2. hello > > _what''s up?_" > > which is being textilized as: > > <h2>hello<br /> > <em>what’s up?</em></h2> > > so no paragraph and h2 wrapped all the way. > > the input is coming from firefox 1.5.2 on a mac > > Anybody got any idea what the problem might be? > > -- > I do things for love or moneyI have had similar issues. It seems to come down to the :hard_breaks option, which is enabled by default. I had to add a hlper method called textilize to application_helper.rb that overrides the default behavior. def textilize(text, options = nil) if text.blank? "" else textilized = (options ? RedCloth.new(text, options) : RedCloth.new(text)) textilized.to_html end end That should make textilize work as expected, and allows you to pass in your option to the RedCloth object. However single line breaks will not produce a <br />. If anyone knows how to make textile work so "\n" is a <br /> and "\n\n" does paragraphs I would be quite interested to know. -- Posted via http://www.ruby-forum.com/.
yeah, that worked. I knew there were problems with hard_breaks and rails in 3.0.3. but that all of this might have been resolved in 3.0.4 I thought that both should be possible. Maybe it''s an either/or thing. It does seem to be a redcloth issue though because textile *should* handle both at the same time. Try doing it here: http://textism.com/tools/textile/index.php Oh well, it''s working ok for now but not ideal. thanks Alex Wayne wrote:> dorian mcfarland wrote: >> Hi, I''m having some problems with redcloth(3.0.4 gem) and textilize. >> >> I have a string: >> "h2. hello >> >> _what''s up?_" >> >> which is being textilized as: >> >> <h2>hello<br /> >> <em>what’s up?</em></h2> >> >> so no paragraph and h2 wrapped all the way. >> >> the input is coming from firefox 1.5.2 on a mac >> >> Anybody got any idea what the problem might be? >> >> -- >> I do things for love or money > > I have had similar issues. It seems to come down to the :hard_breaks > option, which is enabled by default. I had to add a hlper method called > textilize to application_helper.rb that overrides the default behavior. > > def textilize(text, options = nil) > if text.blank? > "" > else > textilized = (options ? RedCloth.new(text, options) : > RedCloth.new(text)) > textilized.to_html > end > end > > That should make textilize work as expected, and allows you to pass in > your option to the RedCloth object. > > However single line breaks will not produce a <br />. If anyone knows > how to make textile work so "\n" is a <br /> and "\n\n" does paragraphs > I would be quite interested to know. > >-- -- I do things for love or money
> However single line breaks will not produce a <br />. If anyone knows > how to make textile work so "\n" is a <br /> and "\n\n" does paragraphs > I would be quite interested to know.I, too, would love to know how to do this with textile/redcloth. Any suggestions with regards to this would be much appreciated!! -raymond
It seems like this was answered, but in case it wasn''t here''s a console dump:>> s="this is\na two line string"=> "this is\na two line string">> RedCloth.new(s).to_html=> "<p>this is\na two line string</p>">> class RedCloth >> def hard_breaks; true; end >> end=> nil>> RedCloth.new(s).to_html=> "<p>this is<br />a two line string</p>" It does come down to hard line breaks. For further reference, see: http://redhanded.hobix.com/inspect/usingRedcloth3.html -- View this message in context: http://www.nabble.com/redcloth+poblems-t1506534.html#a4476275 Sent from the RubyOnRails Users forum at Nabble.com.