[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

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

why the lucky stiff

11/9/2004 2:56:00 PM

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/red...

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



13 Answers

gabriele renzi

11/9/2004 4:49:00 PM

0

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 ?

Jamis Buck

11/9/2004 5:01:00 PM

0

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...


why the lucky stiff

11/9/2004 5:15:00 PM

0

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



Mark Hubbart

11/9/2004 5:26:00 PM

0

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


Tobias Luetke

11/9/2004 5:43:00 PM

0

> 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.le...


gabriele renzi

11/9/2004 6:02:00 PM

0

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..

Jim Weirich

11/9/2004 6:36:00 PM

0


why the lucky stiff said:
> Anyway, it just happened.

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

--
-- Jim Weirich jim@weirichhouse.org http://onest...
-----------------------------------------------------------------
"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)



Stephan Kämper

11/9/2004 10:19:00 PM

0

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/red...
>
> 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.imagem... 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-la..., 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... is a Ruby
implementation of
"Textile":http://www.textism.com/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... offers more information
about it.

* Development Tools

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

* Graphic,Text-/Office-Applications and Utilities

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

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

** "Rmagick":http://rmagick.ruby...

** "TextPad":http://www.te...

** "TotalCommander":http://www.gh... -- 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.gnu... 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.s...

** "Windows&trade;":http://www.micr...

h3. Useful stuff

why the lucky stiff

11/9/2004 11:30:00 PM

0

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


Michael Granger

11/11/2004 5:40:00 PM

0

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

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..

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.FaerieMU...

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

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