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

Discussion in 'Ruby' started by why the lucky stiff, Nov 9, 2004.

  1. 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, Nov 9, 2004
    #1
    1. Advertising

  2. 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 ?
    gabriele renzi, Nov 9, 2004
    #2
    1. Advertising

  3. why the lucky stiff

    Jamis Buck Guest

    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

    http://www.jamisbuck.org/jamis
    Jamis Buck, Nov 9, 2004
    #3
  4. 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
    why the lucky stiff, Nov 9, 2004
    #4
  5. why the lucky stiff

    Mark Hubbart Guest

    Hi,

    On Wed, 10 Nov 2004 01:53:33 +0900, 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 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
    Mark Hubbart, Nov 9, 2004
    #5
  6. > 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
    Tobias Luetke, Nov 9, 2004
    #6
  7. 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..
    gabriele renzi, Nov 9, 2004
    #7
  8. why the lucky stiff

    Jim Weirich Guest

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


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

    --
    -- Jim Weirich 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)
    Jim Weirich, Nov 9, 2004
    #8
  9. 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/>
    >
    > 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
    Stephan Kämper, Nov 9, 2004
    #9
  10. 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
    why the lucky stiff, Nov 9, 2004
    #10
  11. -----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 <>
    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-----
    Michael Granger, Nov 11, 2004
    #11
  12. 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

    >
    Mathieu Boespflug, Nov 13, 2004
    #12
  13. On Tue, 9 Nov 2004 23:55:46 +0900, why the lucky stiff
    <> wrote:
    > 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?

    --
    Dmitry Borodaenko
    Dmitri Borodaenko, Nov 15, 2004
    #13
  14. 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? ;-)
    >


    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
    why the lucky stiff, Nov 15, 2004
    #14
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. why the lucky stiff
    Replies:
    0
    Views:
    97
    why the lucky stiff
    Feb 6, 2004
  2. why the lucky stiff
    Replies:
    0
    Views:
    84
    why the lucky stiff
    Apr 2, 2004
  3. why the lucky stiff
    Replies:
    0
    Views:
    84
    why the lucky stiff
    Apr 8, 2004
  4. why the lucky stiff
    Replies:
    0
    Views:
    93
    why the lucky stiff
    Apr 14, 2004
  5. Belorion

    markdown, textile, etc

    Belorion, Jun 19, 2005, in forum: Ruby
    Replies:
    1
    Views:
    101
    Ryan Leavengood
    Jun 19, 2005
Loading...

Share This Page