Everytime I do to_html with RedCloth it wraps the entire thing in
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
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 fell!”
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.
Everytime I do to_html with RedCloth it wraps the entire thing in
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
tags. Does anyone know
how to disable this?
Have you tried ‘textilize_without_paragraph(text)’?
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.