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

  • Thread starter why the lucky stiff
  • Start date
W

why the lucky stiff

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
 
G

gabriele renzi

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 ?
 
J

Jamis Buck

gabriele said:
why the lucky stiff ha scritto:



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
 
W

why the lucky stiff

gabriele said:
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
 
M

Mark Hubbart

Hi,

why the lucky stiff ha scritto:


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
 
T

Tobias Luetke

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 =)
 
G

gabriele renzi

Tobias Luetke ha scritto:
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..
 
S

Stephan Kämper

Hi,
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/>

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":http://www.ruby-lang.org/en/, 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":http://www.textism.com/tools/textile/index.html. "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":http://onestepback.org/articles/buildingwithrake/, 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;":http://www.suse.de/de/

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

h3. Useful stuff
 
W

why the lucky stiff

Stephan said:
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
---
 
M

Michael Granger

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tobias Luetke ha scritto:


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 <[email protected]>
Rubymage, Architect, Believer
The FaerieMUD Consortium <http://www.FaerieMUD.org/>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (Darwin)

iD8DBQFBk6O/+zlz4UKpE6QRAjIxAKDyC0mIzIFqURAn/7GcU9rAw/dbZgCg8DVs
fQJmObXdCzEJhwnHrqehLhU=
=qyte
-----END PGP SIGNATURE-----
 
M

Mathieu Boespflug

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

Stephan said:
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
 
D

Dmitri Borodaenko

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? ;-)
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?
 
W

why the lucky stiff

Dmitri said:
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? ;-)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top