------art_6855_14540427.1176471724514
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

I think you will be bitten pretty fast with the current approach of
doing only text substitutions while translating HTML into Textile.

For example, HTML is pretty insensitive to some spaces in between:

    <h1>main title</h1> <h2>subtitle</h2>

is just as good as

    <h1>main title</h1>
    <h2>subtitle</h2>

But in Textile,

    h1. main title

    h2. subtitle

is not the same as

    h1. main title h2. subtitle

or even

    h1. main title
    h2. subtitle

In the current implementation, ClothRed behaves like that:

$ irb
irb(main):001:0> require 'rubygems'
true
irb(main):002:0> require 'clothred'
true
irb(main):003:0> t  lothRed.new("<h1>Foo</h1> <h2>Bar</h2>")
"<h1>Foo<h1> <h2>Bar</h2>"
irb(main):004:0> t.to_textile
"h1. Foo  h2. Bar"

but that's pretty easy to work around with the simple patch attached.
I just replaced "" as a substitution to HTML </h1>, </h2>, ... by
"\n\n" producing the necessary paragraph breaks for Textile.
"test/test_headings.rb" had to be fixed and I also wrote
"test/test_misc.rb" as a test script for HTML with more than one tag
in it.

The substitution approach will not work quite right for HTML where
closing tags are missing. The algorithm will never understand when the
tags were closed. So this is somewhat limited currently to XHTML which
demands closing tags.

I think the suggestion of using a HTML parser (like Hpricot) to do
this conversion will impose itself pretty soon.

Thanks for the inspiring work.

Adriano Ferreira.

On 4/12/07, Phillip Gawlowski <cmdjackryan / googlemail.com> wrote:
> Or: TTD is fun.
>
>  lothRed HTML 2 Textile converter
>
> What it is
>
> A library to convert HTML into Textile markup for use, for example, with
> RedCloth.
>
>
> Requirements
>
> All you need is Ruby.
>
> Get it
>
> Available as a gem on RubyForge:
> gem install ClothRed
>
> Or download from RubyForge:
> http://rubyforge.org/frs/?group_id427
>
> Or get the source:
> svn checkout svn://viewvc.rubyforge.mmmultiworks.com/var/svn/clothred
>
> New in this release:
>    * Support for some HTML entities
>    * Support for tables
>
> Features
>
> This is alpha software, and only a few Textile rules have been
> implemented yet:
>   * font markup and weight (<b>, <strong>, ...)
>   * text formatting (<sub>, <sup>, <ins>,<del>)
>   * Support for headings
>   * Support for paragraphs and <blockquote>
>   * Support for Textile entities
>
> Usage
>
> require 'clothred'
>
> text  lothRed.new("<b>Bold</b> <em>HTML</em>!")
> text.to_textile
>
> Get Help
> Feel free to contact me, or peruse the homepage.
>
>   * http://clothred.rubyforge.org/
>   * http://rubyforge.org/projects/clothred/
>
> --
> Phillip "CynicalRyan" Gawlowski
> http://cynicalryan.110mb.com/
> http://clothred.rubyforge.org
>
> Rule of Open-Source Programming #11:
>
> When a developer says he will work on something, he or she means
> "maybe".
>
>

------art_6855_14540427.1176471724514
Content-Type: application/octet-stream; name=clothred.diff
Content-Transfer-Encoding: base64
X-Attachment-Id: f_f0gorskc
Content-Disposition: attachment; filename="clothred.diff"

ZGlmZiAtdSAtciAtTiBjbG90aHJlZC9saWIvY2xvdGhyZWQucmIgbmV3L2xpYi9jbG90aHJlZC5y
YgotLS0gY2xvdGhyZWQvbGliL2Nsb3RocmVkLnJiCTIwMDctMDQtMTMgMTA6MzQ6MjQuMDAwMDAw
MDAwIC0wMzAwCisrKyBuZXcvbGliL2Nsb3RocmVkLnJiCTIwMDctMDQtMTMgMTA6MzU6MTAuMDAw
MDAwMDAwIC0wMzAwCkBAIC0yMywxMCArMjMsMTAgQEAKICAgXQogICAKICAgSEVBRElOR1MgPSBb
Ci0gICAgWyI8aDE+IiwiaDEuICJdLCBbIjwvaDE+IiwgIiJdLCBbIjxoMj4iLCJoMi4gIl0sIFsi
PC9oMj4iLCAiIl0sIAotICAgIFsiPGgzPiIsImgzLiAiXSwgWyI8L2gzPiIsICIiXSwgWyI8aDQ+
IiwiaDQuICJdLCBbIjwvaDQ+IiwgIiJdLCAKLSAgICBbIjxoNT4iLCJoNS4gIl0sIFsiPC9oNT4i
LCAiIl0sIFsiPGg2PiIsImg2LiAiXSwgWyI8L2g2PiIsICIiXSwgCi0gICAgWyI8aDc+IiwiaDcu
ICJdLCBbIjwvaDc+IiwgIiJdCisgICAgWy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