Hi,
First, I support any move to fix RedCloth! So SuperRedCloth as v4 seems
great to me!
FYI, for anyone who cares, I''m working around my problems with RedCloth
and hard breaks by postprocessing the resulting html like so, which
converts any <br /> followed by a newline into <p /> followed by a
newline. It''s not perfect of course, but seems to fit my most painful
issues:
retval = textilize(h(value))
retval.gsub(%r{<br />\s*\n}, "<p />\n")
Also, I see some mention of v3.03 or tip revision as being preferred to
v3.04?
Can anyone provide a short description of what''s better about 3.03 or
tip? And how I might go about deciding to change to one of these
versions?
Thanks,
Steve
At 02:35 PM 1/23/2007, redcloth-upwards-request at rubyforge.org
wrote:>Message: 6
>Date: Tue, 16 Jan 2007 12:41:32 -0800
>From: Steve Midgley <public at misuse.org>
>Subject: <BR> and <P> in RedCloth v. Textism
>To: redcloth-upwards at rubyforge.org.
>Message-ID: <20070116204855.26B8D524159A at rubyforge.org>
>Content-Type: text/plain; charset="us-ascii"
>
>Hi,
>
>I''m using RedCloth right now for some simple markup in a Rails
>project.
>It''s simple and easy - thanks for a great tool!
>
>I have a question about an apparent discrepancy between RedCloth and
>Textile, relating to newline characters. I''ve played with the
>"hard_breaks" feature and that seems to generate it''s own
problems..
>
>If I go onto the Textile test page:
>
>http://www.textism.com/tools/textile/index.php
>
>And enter the following text:
>
>test
>text
>
>other
>
>I get back:
>
> <p>test<br />
>text</p>
>
> <p>other</p>
>
>In IRB if I try to feed an equivalent string to RedCloth I get
>(accounting for hard_breaks on and off here):
>
>irb(main):006:0> val = RedCloth.new("test\ntext\n\nother")
>=> "test\ntext\n\nother"
>irb(main):007:0> val.hard_breaks = true
>=> true
>irb(main):008:0> val.to_html
>=> "<p>test<br />text<br />\nother</p>"
>irb(main):009:0> val.hard_breaks = false
>=> false
>irb(main):010:0> val.to_html
>=> "<p>test\ntext</p>\n\n\n\t<p>other</p>
"
>
>Basically, RedCloth either passes the single newline between
"test"
>and
>"text" unparsed, or it adds only <br /> tags and fails to
create the
>correct <p> tag for "other"..
>
>Textile seems to convert the single newline into a <br /> character
>and
>the double newline into a <p> tag. The Textile behavior is greatly
>preferred for me.
>
>I snooped around in the redcloth.rb source file and found this on line
>
>597:
>
> def hard_break( text )
> text.gsub!( /(.)\n(?!\Z| *([#*=]+(\s|$)|[{|]))/, "\\1<br
/>"
> )
>if hard_breaks
> end
>
>I believe that the problem is that this gsub is not accounting for the
>
>idea that there might be two newlines consecutively (or separated only
>
>by whitespace). In the case where there are two such newlines, I
>believe this pattern should not match and therefore the double
>newlines
>will be handed off for additional (correct) processing by the
>paragraph
>generator, rather than only one of them being sub''ed with a <br
/>
>tag.
>I tried just changing "(.)" to "([^\n])" but that
didn''t have the
>effect I was looking for..
>
>I''d be happy to do a little work if someone can give me direction
on
>patching this issue - this regex is pretty complicated and seems
>loaded
>with assumptions that I don''t understand, so I''m hesitant
to monkey
>with it without help.
>
>Or am I barking up a non-existent tree? Is there a way already to do
>what I want without a code change?
>
>Thanks for any insight and assistance and especially for such a great
>tool!
>
>Steve
>
>p.s. I saw these postings in the archives which are related:
>http://rubyforge.org/pipermail/redcloth-upwards/2006-June/000041.html
>http://rubyforge.org/pipermail/redcloth-upwards/2006-August/000077.html
>
>June 2006 claims that the exact problem I have is fixed! But I''m
still
>
>having it.. Any patch around that can help?!
>
>p.p.s. (I''m on version 3.0.4, at least according the folder that
it''s
>installed - I did a gems install but just compared that to the tar.gz
>file from the website, which is the same..)
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/redcloth-upwards/attachments/20070124/8c126af1/attachment.html