From ahodgkin at rowing.org.uk Fri Aug 4 10:49:29 2006 From: ahodgkin at rowing.org.uk (Andrew Hodgkinson) Date: Fri, 04 Aug 2006 14:49:29 +0000 Subject: Hard break broken in 3.0.4? Message-ID: <44D35E79.60504@rowing.org.uk> Is :hard_break working in RedCloth 3.0.4? $ ruby -v ruby 1.8.4 (2005-12-24) [i686-linux] $ pwd /lib/ruby/gems/1.8/gems/RedCloth-3.0.4/lib $ irb irb(main):001:0> require 'redcloth' => true irb(main):002:0> rc = RedCloth.new("h1. Heading\n\n_Not_ heading.") => "h1. Heading\n\n_Not_ heading." irb(main):003:0> rc.to_html(:textile) => "

Heading

\n\n\n\t

Not heading.

" All good so far. But now: irb(main):004:0> rc.hard_breaks = true => true irb(main):005:0> rc.to_html(:textile) => "

Heading
\nNot heading.

" Ooops - that's definitely not right. I originally thought there was some kind of interaction with Rails 1.1.4, because my Instiki installation went nuts when a sysadmin upgraded from Rails 1.1.0 to 1.1.4. But surely RedCloth has no dependencies upon Rails, so it is presumably a concurrent upgrade of the RedCloth gem (from what is, I'm afraid, an unknown earlier version) that has introduced the problem. BTW, filter_html might be broken too - this doesn't look like what I'd expect it to do at all: irb(main):002:0> rc = RedCloth.new("Escape
This .") => "Escape
This ." irb(main):003:0> rc.to_html(:textile) => "

Escape
This .

" irb(main):004:0> rc.filter_html = true => true irb(main):005:0> rc.to_html(:textile) => "

Escape
This .

" -- TTFN, Andrew Hodgkinson Find some electronic music at: All sorts of other bits and pieces at: http://www.ampcast.com/pond http://pond.org.uk/ From chris at ozmm.org Tue Aug 22 22:33:04 2006 From: chris at ozmm.org (Chris Wanstrath) Date: Tue, 22 Aug 2006 19:33:04 -0700 Subject: emdash vs Message-ID: Hey guys. Is this a bug or what? >> RedCloth.new("First part -- middle part -- end part.").to_html => "

First part - middle part - end part.

" But http://textism.com/tools/textile/index.php says the output should be:

First part—middle part—end part.

Thing is, I *want* textism.com's output. Here's my workaround: >> RedCloth.new("First part-- middle part -- end part.").to_html => "

First part—middle part—end part.

" (No space after 'First part') That's a little less natural for the non-techies who will be entering Textile data on my site. Is this a known issue, or is RedCloth correct? Thanks. -- Chris Wanstrath http://errtheblog.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/redcloth-upwards/attachments/20060822/e33c15db/attachment.html From fabienpenso at gmail.com Mon Aug 28 09:21:37 2006 From: fabienpenso at gmail.com (Fabien Penso) Date: Mon, 28 Aug 2006 15:21:37 +0200 Subject: bug / infinite loop Message-ID: <89fe6f1b0608280621h2b17a5aen8cf7c685cb1850b1@mail.gmail.com> Hi. I spent about 10 hours on saturday trying to understand why my blog/Typo was taking more than 500M and then crashing my server. There is a recursive function in redcloth.rb which is not written properly (a variant is in the parameters, but is not even checked. Variant is existing to be checked, not just print a debug...). Here is the patch to prevent this. Please apply them and release something soon because it's really nasty. -- http://penso.info/ -------------- next part -------------- --- redcloth.rb.old 2006-08-28 15:13:55.000000000 +0200 +++ redcloth.rb 2006-08-28 15:14:35.000000000 +0200 @@ -980,7 +980,10 @@ HASTAG_MATCH = /(<\/?\w[^\n]*?>)/m ALLTAG_MATCH = /(<\/?\w[^\n]*?>)|.*?(?=<\/?\w[^\n]*?>|$)/m - def glyphs_textile( text, level = 0 ) + def glyphs_textile( text, level = 50 ) + if level < 0 + return + end if text !~ HASTAG_MATCH pgl text footnote_ref text @@ -996,7 +999,7 @@ codepre = 0 if codepre < 0 end elsif codepre.zero? - glyphs_textile( line, level + 1 ) + glyphs_textile( line, level - 1 ) else htmlesc( line, :NoQuotes ) end From mat.mannion at gmail.com Tue Aug 29 07:06:15 2006 From: mat.mannion at gmail.com (Mat Mannion) Date: Tue, 29 Aug 2006 12:06:15 +0100 Subject: Several bug-fixes and improvements(?) Message-ID: Hey guys, I have been working with RedCloth for the past week or so in order to try and upgrade a University's blog system (blogs.warwick.ac.uk) to Textile2, having used a bespoke Java-based Textile1 implementation in the past. As such, it's been an important part of this that it works as much as possible to give the same results for Textile1 code, but with the added features (footnotes, tables) of Textile2. The RedCloth 3.0.4 release gave me too many headaches, so I've been working with the latest out of SVN and I think I've uncovered a few bugs that I'd be interested in sharing the code for if anyone wants it: (All of the changes are to base.rb) Auto-magic URLs: There's a couple of things that were a little iffy. Firstly, I changed it so that the parsing for auto-magic linking of normal links AND emails are done twice (so I added the rule twice to TEXTILE_RULES in both cases): TEXTILE_RULES = [:refs_textile, :block_textile_table, :block_textile_lists, :block_textile_defs, :block_textile_prefix, :inline_textile_image, :inline_textile_link, :inline_textile_code, :inline_textile_span, :glyphs_textile, :inline_textile_autolink_urls, :inline_textile_autolink_urls, :inline_textile_autolink_emails, :inline_textile_autolink_emails] # do these twice to accomodate for one space/line diffs This fixes any problems with two URLs appearing with a single space or linebreak between them. Also, the AUTO_LINK_RE regular expression has a bug, where it matches any character in the leading punctuation (I think the intention was to have a list of punctuation to be not matched, but that means it matches any character that isn't punction, including word characters). I changed this to have a list of "whitelisted" punctuation (I only needed the open-bracket at the moment) and also to match any whitespace preceding the link: AUTO_LINK_RE = / ( # leading text <\w+.*?>| # leading HTML tag, or [\(]| # selected punctuation, or \s| # whitespace, or ^ # beginning of line ) ( (?:http[s]?:\/\/)| # protocol spec, or (?:www\.) # www.* ) ( ([\w]+[=?&:%\/\.\~\-]*)* # url segment \w+[\/]? # url tail (?:\#\w*)? # trailing anchor ) ([[:punct:]]|\s|<|$) # trailing text /x The IMAGE_RE regular expression also has a bug, where it matches any character (.) for the start of a line. I replaced this with any whitespace. Also, I made it so that the URL for a link *must* have a . in it: IMAGE_RE = / (\|\s|^) # start of line? \! # opening (\<|\=|\>)? # optional alignment atts (#{C}) # optional style,class atts (?:\. )? # optional dot-space ([^\s(!]+?\.[^\s(!]+?) # presume this is the src \s? # optional space (?:\(((?:[^\(\)]|\([^\)]+\))+?)\))? # optional title \! # closing (?::#{ HYPERLINK })? # optional href /x I made a couple of minor other alterations, such as adding the sterling (?) symbol to the glyphs to be replaced with £, and adding a newline after
when hard_breaks are turned on to help readability. In order to work well with our implementation, I also added an escape capability, to allow a user to write \*text\* without the asterisks being converted to tags. If anyone wants the code for this then feel free to ask, I'm wary about committing anything to SVN unless it's really wanted/needed Regards, Mat -- Mat Mannion Web Developer e-lab, University of Warwick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/redcloth-upwards/attachments/20060829/a642efd7/attachment-0001.html