Everytime I do to_html with RedCloth it wraps the entire thing in <p> which is really annoying. I''ve looked all over for an answer on how to disable this but I''ve found nothing. I''m surprised that I''m the only one that doesn''t want my stuff wrapped in <p> tags. Does anyone know how to disable this? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
This may or may not help you depending on which RedCloth functionality you need. From http://redcloth.rubyforge.org/classes/RedCloth/TextileDoc.html lite_mode [RW] Accessor for toggling lite mode. In lite mode, block-level rules are ignored. This means that tables, paragraphs, lists, and such aren''t available. Only the inline markup for bold, italics, entities and so on. r = RedCloth.new( "And then? She *fell*!", [:lite_mode] ) r.to_html #=> "And then? She <strong>fell</strong>!" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks, that''s getting closer to what I want. :) But I''d still like things enabled such as lists...does that have further options like a whitelist? On Jan 12, 4:21 pm, "Adam Kittelson" <adam.kittel...-ior1xYNzzWhCuqJiA0mxOA@public.gmane.org> wrote:> This may or may not help you depending on which RedCloth functionality you need. > > Fromhttp://redcloth.rubyforge.org/classes/RedCloth/TextileDoc.html > > lite_mode [RW] Accessor for toggling lite mode. > > In lite mode, block-level rules are ignored. This means that tables, > paragraphs, lists, and such aren''t available. Only the inline markup > for bold, italics, entities and so on. > > r = RedCloth.new( "And then? She *fell*!", [:lite_mode] ) > r.to_html > #=> "And then? She <strong>fell</strong>!"--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Well... you could remove the <p> tags with a regular expression, but that would remove all <p> tags, even ones caused intentionally via p. or having two lines. ie: foo.to_html.gsub(/<\/?p>/, '''') On Tue, Jan 13, 2009 at 2:12 PM, Mike C <snibble-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Thanks, that''s getting closer to what I want. :) But I''d still like > things enabled such as lists...does that have further options like a > whitelist? > > On Jan 12, 4:21 pm, "Adam Kittelson" <adam.kittel...-ior1xYNzzWhCuqJiA0mxOA@public.gmane.org> > wrote: > > This may or may not help you depending on which RedCloth functionality > you need. > > > > Fromhttp://redcloth.rubyforge.org/classes/RedCloth/TextileDoc.html > > > > lite_mode [RW] Accessor for toggling lite mode. > > > > In lite mode, block-level rules are ignored. This means that tables, > > paragraphs, lists, and such aren''t available. Only the inline markup > > for bold, italics, entities and so on. > > > > r = RedCloth.new( "And then? She *fell*!", [:lite_mode] ) > > r.to_html > > #=> "And then? She <strong>fell</strong>!" > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hmm Yeah I guess so but I do want some <p> tags in there, just not appended all the time. I looked around and found that I could just manually remove the p tags if they''re there, but it caused a bunch of other problems like not being XSS safe anymore. Now I''m using RedCloth with a white_list plugin and it works, but I''m still worried about the performance. On Jan 13, 1:04 pm, "Adam Kittelson" <adam.kittel...-ior1xYNzzWhCuqJiA0mxOA@public.gmane.org> wrote:> Well... you could remove the <p> tags with a regular expression, but that > would remove all <p> tags, even ones caused intentionally via p. or having > two lines. > > ie: foo.to_html.gsub(/<\/?p>/, '''') > > On Tue, Jan 13, 2009 at 2:12 PM, Mike C <snib...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Thanks, that''s getting closer to what I want. :) But I''d still like > > things enabled such as lists...does that have further options like a > > whitelist? > > > On Jan 12, 4:21 pm, "Adam Kittelson" <adam.kittel...-ior1xYNzzWhCuqJiA0mxOA@public.gmane.org> > > wrote: > > > This may or may not help you depending on which RedCloth functionality > > you need. > > > > Fromhttp://redcloth.rubyforge.org/classes/RedCloth/TextileDoc.html > > > > lite_mode [RW] Accessor for toggling lite mode. > > > > In lite mode, block-level rules are ignored. This means that tables, > > > paragraphs, lists, and such aren''t available. Only the inline markup > > > for bold, italics, entities and so on. > > > > r = RedCloth.new( "And then? She *fell*!", [:lite_mode] ) > > > r.to_html > > > #=> "And then? She <strong>fell</strong>!"--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mike Chai wrote:> Everytime I do to_html with RedCloth it wraps the entire thing in <p> > which is really annoying. I''ve looked all over for an answer on how to > disable this but I''ve found nothing. I''m surprised that I''m the only > one that doesn''t want my stuff wrapped in <p> tags. Does anyone know > how to disable this?Have you tried ''textilize_without_paragraph(text)''? taken from: http://api.rubyonrails.com/classes/ActionView/Helpers/TextHelper.html#M001717 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Also if you don''t want to use the textilize helper because you want to include your own options then you can make your own helper using the same code from the textilize helper and throw in your options. ie: def textilize_with_filter_no_paragraph(text) if text.blank? "" else textilized = RedCloth.new(text, [:filter_html]) textilized.hard_breaks = true if textilized.respond_to?(:hard_breaks=) textiled = textilized.to_html if textiled[0..2] == "<p>" then textiled = textiled[3..-1] end if textiled[-4..-1] == "</p>" then textiled = textiled[0..-5] end return textiled end end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---