[ANN] RedCloth 3.0.0 -- Textile and Markdown Elope!

RedCloth 3 is out. You know? RedCloth? Perhaps you've heard of it. Or perhaps you've used Textile, the simple text markup it parses. Okay, well then: RedCloth turns Textile markup into HTML.

   <http://www.whytheluckystiff.net/ruby/redcloth/>

But RedCloth's gaze has fallen upon new text formats to devour. The new RedCloth 3 adds preliminary support for Markdown. This means that you can intermingle Textile and Markdown together!

RedCloth 3 uses the API of yore:

   RedCloth.new( "I *stole* an orange." ).to_html
   => "<p>I <strong>stole</strong> an orange.</p>"

But now you can apply processing rules in order of descending precedence. By default, the Textile engine takes precedence. But, if you want the Markdown engine to be applied first:

   RedCloth.new( str ).to_html( :markdown, :textile )

Or, use only the Markdown engine:

   RedCloth.new( str ).to_html( :markdown )

RedCloth also allows nesting elements through indentation. To include a paragraph in a list item:

   ToDo

···

====
   # Add Markdown lists

     Allow lists fronted by digits,
     followed by a period

RedCloth now generates valid XHTML 1.0 Strict fragments. Stuff like image borders and alignment of elements are done using CSS.

RedCloth also now allows you to add your own custom Textile block tags. I'll divulge all the HOWTO later on my site.

RedCloth should also handle complete HTML documents with embedded Textile. I know plenty of you have been asking for this.

Okay, yeah, you get the point: lots.

_why

why the lucky stiff ha scritto:

But RedCloth's gaze has fallen upon new text formats to devour. The new RedCloth 3 adds preliminary support for Markdown.

I wonder: why add markdown support to RedCloth if it is already available in BLueCloth ?

Hi,

why the lucky stiff wrote:

RedCloth 3 is out. You know? RedCloth? Perhaps you've heard of it. Or

Yes. I use it a lot.

perhaps you've used Textile, the simple text markup it parses. Okay, well then: RedCloth turns Textile markup into HTML.

  <http://www.whytheluckystiff.net/ruby/redcloth/&gt;

But RedCloth's gaze has fallen upon new text formats to devour. The new RedCloth 3 adds preliminary support for Markdown. This means that you can intermingle Textile and Markdown together!

However I ran into a stragne, um ...ommm, behaviour, I don't understand.
Perhaps something is wrong with my RedCloth?

When I run this code,

--- code starts here ---
require 'redcloth'
puts "Running RedCloth #{RedCloth::VERSION}"
f = 'test.rdcl'
puts "*"*80, f, "*"*80
rc = RedCloth.new( File.read( f ) )
puts rc.to_html
File.open( 'rc.html', 'wb'){ | file | file.puts rc.to_html }
--- code ends here ---

.... I get that result:

Running RedCloth 3.0.0

···

********************************************************************************
test.rdcl
********************************************************************************
C:/ruby/lib/ruby/gems/1.8/gems/RedCloth-3.0.0/lib/redcloth.rb:592: warning: ambiguous first argument; put parentheses or even spaces
C:/ruby/lib/ruby/gems/1.8/gems/RedCloth-3.0.0/lib/redcloth.rb:802: warning: ambiguous first argument; put parentheses or even spaces
C:/ruby/lib/ruby/gems/1.8/gems/RedCloth-3.0.0/lib/redcloth.rb:1001: warning: ambiguous first argument; put parentheses or even spaces
C:/ruby/lib/ruby/gems/1.8/gems/RedCloth-3.0.0/lib/redcloth.rb:785: warning: method redefined; discarding old inline_markdown_link
C:/ruby/lib/ruby/gems/1.8/gems/RedCloth-3.0.0/lib/redcloth.rb:423: warning: instance variable @filter_styles not initialized
C:/ruby/lib/ruby/gems/1.8/gems/RedCloth-3.0.0/lib/redcloth.rb:566:in `gsub!': Stack overflow in regexp matcher: /((?:\n*[\# ](?:[^\n]|\n+[\# ]|\n(?!\n|\Z))+)|(?:\n*[\* ](?:[^\n]|\n+[\* ]|\n(?!\n|\Z))+)|(?:\n*[> ](?:[^\n]|\n+[> ]|\n(?!\n|\Z))+))|((?:[^\n]+|\n+ +|\n(?![#*\n]|\Z))+)/m (RegexpError)
  from C:/ruby/lib/ruby/gems/1.8/gems/RedCloth-3.0.0/lib/redcloth.rb:566:in `blocks'
  from C:/ruby/lib/ruby/gems/1.8/gems/RedCloth-3.0.0/lib/redcloth.rb:276:in `to_html'
  from E:/stephan/source/zz_delete-me/rc_3.rb:6

The test file is at the end of the message.

What makes me kind of clueless is this: Whatever I remove, the overflow disappears. Even removing a single word (doesn't work with all words though...) - overflow's gone.
For example removing 'an ' from the line >>>\t** "ImageMagick":http://www.imagemagick.org/ is an OpenSource tool for graphics manipulation.<<< will get rid of the overflow. However grammatically that's not an option, I think.

This happens on both Linux running Ruby 1.8.2 (preview2) and WinXP running the 1-click-installer (1.8.2 too).
Ah well, the behaviour doesn't happen in 2.0.11.

Any help would be greatly appreciated.

Happy rubying

Stephan

--- test.rdcl follows until the end of the message body
h2. Software & Tools

* Programming Languages and Data Formats

  ** "Ruby":Ruby Programming Language, is purely object-oriented. If offers a flexible Syntax and is easy to learn. Furthermore working with it is quite productive.
  ** "RedCloth":http://www.whytheluckystiff.net/ruby/redcloth/ is a Ruby implementation of "Textile":Textism: Tools: Textile. "Textile is a text format. A very simple text format", says _why_the_lucky_stiff author of RedCloth. The "RedCloth Project":http://rubyforge.org/projects/redcloth/ offers more information about it.

* Development Tools

  ** "Rake":http://rubyforge.org/projects/rake/ is like "make" -- but it's entirely written in Ruby. A rake introduction is on the site of "Jim Weirich":Rake - Building with Rake, author of this software
  ** "Subversion":http://subversion.tigris.org/ is an Open Source version control system. Subversion runs on both, Linux and Windows. "TortoiseSVN":http://tortoisesvn.tigris.org/ is a convenient and comfortable GUI client for Windows.

* Graphic,Text-/Office-Applications and Utilities

  ** "OpenOffice.org":http://www.openoffice.org/

  ** "ImageMagick":http://www.imagemagick.org/ is an OpenSource tool for graphics manipulation.

  ** "Rmagick":http://rmagick.rubyforge.org/

  ** "TextPad":http://www.textpad.com/

  ** "TotalCommander":http://www.ghisler.com/ -- if you liked the "Norton Commander", you'll probably like this tool. It's a files system browser offering a lot of additional features

  ** "GnuPlot":http://www.gnuplot.info/ you can interactively (and automatically) display data plots. To a certain extent data analysis is possible, too.<br>

* Operating systems -- in _alphbetical_ order

  ** "Linux&trade;":SUSE – Open-Source-Lösungen für Enterprise Server und Cloud | SUSE

  ** "Windows&trade;":http://www.microsoft.com/

h3. Useful stuff

RedCloth 3 is out.

Cool! I checked it over this weekend and it mostly works fine, even a
bit faster than before. But my favorite :filter_html bug is still
there... Wanna borrow my sanitize.rb? :wink:

RedCloth now generates valid XHTML 1.0 Strict fragments. Stuff like
image borders and alignment of elements are done using CSS.

I noticed that !<img.png! is now rendered as <p
style="text-align:left"><img src="img.png" alt="" /></p> and I have to
write !{float: left}img.png! to make the image float. Was that
intentional?

···

On Tue, 9 Nov 2004 23:55:46 +0900, why the lucky stiff <ruby-talk@whytheluckystiff.net> wrote:

--
Dmitry Borodaenko

gabriele renzi wrote:

why the lucky stiff ha scritto:

But RedCloth's gaze has fallen upon new text formats to devour. The new RedCloth 3 adds preliminary support for Markdown.

I wonder: why add markdown support to RedCloth if it is already available in BLueCloth ?

I can think of one reason: BlueCloth is GPL'd, and RedCloth isn't. If licensing is an issue, this gives you more Ruby-based solutions to choose from.

- Jamis

···

--
Jamis Buck
jgb3@email.byu.edu
http://www.jamisbuck.org/jamis

gabriele renzi wrote:

I wonder: why add markdown support to RedCloth if it is already available in BLueCloth ?

To allow Textile and Markdown syntax to be used simultaneously. (Hint: on a wiki.) Or you can mix-n-match.

Anyway, it just happened.

_why

Hi,

···

On Wed, 10 Nov 2004 01:53:33 +0900, gabriele renzi <rff_rff@remove-yahoo.it> wrote:

why the lucky stiff ha scritto:

>
> But RedCloth's gaze has fallen upon new text formats to devour. The new
> RedCloth 3 adds preliminary support for Markdown.

I wonder: why add markdown support to RedCloth if it is already
available in BLueCloth ?

I really like the idea of being able to mix markdown and textile...
That way you can mix the best parts of each one. Also, it removes a
dependency; you can get textile and markdown in one library.

cheers,
Mark

Stephan Kämper wrote:

C:/ruby/lib/ruby/gems/1.8/gems/RedCloth-3.0.0/lib/redcloth.rb:566:in `gsub!': Stack overflow in regexp matcher: /((?:\n*[\# ](?:[^\n]|\n+[\# ]|\n(?!\n|\Z))+)|(?:\n*[\* ](?:[^\n]|\n+[\* ]|\n(?!\n|\Z))+)|(?:\n*[> ](?:[^\n]|\n+[> ]|\n(?!\n|\Z))+))|((?:[^\n]+|\n+ +|\n(?![#*\n]|\Z))+)/m (RegexpError)
    from C:/ruby/lib/ruby/gems/1.8/gems/RedCloth-3.0.0/lib/redcloth.rb:566:in `blocks'
    from C:/ruby/lib/ruby/gems/1.8/gems/RedCloth-3.0.0/lib/redcloth.rb:276:in `to_html'
    from E:/stephan/source/zz_delete-me/rc_3.rb:6

Try the patch below. Also, for simple transformations like the one you're doing, you might try the new `redcloth' command line tool, which simply runs a transformation on a provided text file.

  stungun$ redcloth test.rdcl

Thanks for reporting this right away. The new RedCloth 3.0 needs testing and beating up. Some Markdown stuff just simply doesn't work, other things work wrong, and still other things are just sordid and I won't discuss them here in the presence of professionals.

_why

···

===================================================================
RCS file: /var/cvs/redcloth/redcloth/lib/redcloth.rb,v
retrieving revision 1.46
diff -r1.46 redcloth.rb
558,563c558
< BLOCKS_GROUP_RE = /(#{
< ['#', '*', '>'].collect do |sym|
< sym = Regexp::quote( sym )
< '(?:\n*[' + sym + ' ](?:[^\n]|\n+[' + sym + ' ]|\n(?!\n|\Z))+)'
< end.join '|'
< })|((?:[^\n]+|\n+ +|\n(?![#*\n]|\Z))+)/m
---
> BLOCKS_GROUP_RE = /((?:\n*([#*> ])(?:[^\n]|\n+\2|\n(?!\n|\Z))+))|((?:[^\n]+|\n+ +|\n(?![#*\n]|\Z))+)/m
567c562
< plain = $2 ? true : false
---
> plain = $3 ? true : false

Dmitri Borodaenko wrote:

Cool! I checked it over this weekend and it mostly works fine, even a
bit faster than before. But my favorite :filter_html bug is still
there... Wanna borrow my sanitize.rb? :wink:

The filter_html stuff is being rewritten to allow you to filter out certain elements and attributes. I'm almost there.

I noticed that !<img.png! is now rendered as <p
style="text-align:left"><img src="img.png" alt="" /></p> and I have to
write !{float: left}img.png! to make the image float. Was that
intentional?

Well, yes. But it's now like you've got it. I've switched to `float' rather than `text-align', so look for this in CVS today.

_why

I can think of one reason: BlueCloth is GPL'd, and RedCloth isn't. If
licensing is an issue, this gives you more Ruby-based solutions to
choose from.

I just found out that my commercial ruby application ought to be GPL
because i used bluecloth.
I'll switch to RedCloths markdown in record time =)

···

--
Tobi
http://blog.leetsoft.com

why the lucky stiff said:

Anyway, it just happened.

I find this to be the justification for many software features. :slight_smile:

···

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

Hi _why,

I'm having stack overflows in the regexp engine as well. I applied the patch below but it hasn't solved the problem. On my box (x86-netbsd) tests/images.yml fails with

./redcloth.rb:566:in `gsub!': Stack overflow in regexp matcher: /((?:\n*[\# ](?:[^\n]|\n+[\# ]|\n(?!\n|\Z))+)|(?:\n*[\* ](?:[^\n]|\n+[\* ]|\n(?!\n|\Z))+)|(?:\n*[> ](?:[^\n]|\n+[> ]|\n(?!\n|\Z))+))|((?:[^\n]+|\n+ +|\n(?![#*\n]|\Z))+)/m (RegexpError)
from ./redcloth.rb:566:in `blocks'
from ./redcloth.rb:276:in `to_html'
from ../bin/redcloth:3

This is with RedCloth 3.0 and ruby ruby 1.8.1.

Regards,

Mathieu

···

On Wed, Nov 10, 2004 at 08:30:12AM +0900, why the lucky stiff wrote:

Stephan K?mper wrote:

>C:/ruby/lib/ruby/gems/1.8/gems/RedCloth-3.0.0/lib/redcloth.rb:566:in
>`gsub!': Stack overflow in regexp matcher: /((?:\n*[\#
>](?:[^\n]|\n+[\# ]|\n(?!\n|\Z))+)|(?:\n*[\* ](?:[^\n]|\n+[\*
>]|\n(?!\n|\Z))+)|(?:\n*[> ](?:[^\n]|\n+[>
>]|\n(?!\n|\Z))+))|((?:[^\n]+|\n+ +|\n(?![#*\n]|\Z))+)/m (RegexpError)
> from
>C:/ruby/lib/ruby/gems/1.8/gems/RedCloth-3.0.0/lib/redcloth.rb:566:in
>`blocks'
> from
>C:/ruby/lib/ruby/gems/1.8/gems/RedCloth-3.0.0/lib/redcloth.rb:276:in
>`to_html'
> from E:/stephan/source/zz_delete-me/rc_3.rb:6

Try the patch below. Also, for simple transformations like the one
you're doing, you might try the new `redcloth' command line tool, which
simply runs a transformation on a provided text file.

stungun$ redcloth test.rdcl

Thanks for reporting this right away. The new RedCloth 3.0 needs
testing and beating up. Some Markdown stuff just simply doesn't work,
other things work wrong, and still other things are just sordid and I
won't discuss them here in the presence of professionals.

_why

===================================================================
RCS file: /var/cvs/redcloth/redcloth/lib/redcloth.rb,v
retrieving revision 1.46
diff -r1.46 redcloth.rb
558,563c558
< BLOCKS_GROUP_RE = /(#{
< ['#', '*', '>'].collect do |sym|
< sym = Regexp::quote( sym )
< '(?:\n*[' + sym + ' ](?:[^\n]|\n+[' + sym + '
]|\n(?!\n|\Z))+)'
< end.join '|'
< })|((?:[^\n]+|\n+ +|\n(?![#*\n]|\Z))+)/m
---
> BLOCKS_GROUP_RE = /((?:\n*([#*>
])(?:[^\n]|\n+\2|\n(?!\n|\Z))+))|((?:[^\n]+|\n+ +|\n(?![#*\n]|\Z))+)/m
567c562
< plain = $2 ? true : false
---
> plain = $3 ? true : false

Tobias Luetke ha scritto:

I can think of one reason: BlueCloth is GPL'd, and RedCloth isn't. If
licensing is an issue, this gives you more Ruby-based solutions to
choose from.

I just found out that my commercial ruby application ought to be GPL
because i used bluecloth.
I'll switch to RedCloths markdown in record time =)

maybe you could ask the authors to change the license..

Since the library that I derived Bluecloth from (Markdown.pl) is GPL, I don't have that liberty, unfortunately. I wouldn't have chosen the GPL if it weren't for that.

- --
Michael Granger <ged@FaerieMUD.org>
Rubymage, Architect, Believer
The FaerieMUD Consortium <http://www.FaerieMUD.org/&gt;

···

On Nov 9, 2004, at 10:03 AM, gabriele renzi wrote:

Tobias Luetke ha scritto:

I can think of one reason: BlueCloth is GPL'd, and RedCloth isn't. If
licensing is an issue, this gives you more Ruby-based solutions to
choose from.

I just found out that my commercial ruby application ought to be GPL
because i used bluecloth.
I'll switch to RedCloths markdown in record time =)

maybe you could ask the authors to change the license..