Perhaps something like this? It's ugly, but it works.
require 'rubygems'
require 'haml'
require 'haml/html'
require 'redcloth'
# Method that converts HAML to HTML
def haml2html(haml_data, haml_options = {})
Haml::Engine.new(haml_data, haml_options).render
end
# Method that imports textile inte a HAML template, fixing indentation
def import_textile(textile_data, textile2html_options = {},
html2haml_options = {}, haml2html_options = {})
data = textile_data
data = textile2html(data, textile2html_options)
data = html2haml(data, html2haml_options)
data = haml2html(data, haml2html_options)
data
end
# Method that converts HTML to HAML
def html2haml(html_data, haml_options = {})
Haml::HTML.new(html_data, haml_options).render
end
# Method that converts Textile to HTML
def textile2html(textile_data, textile_options = {})
RedCloth.new(textile_data, textile_options).to_html
end
# Example usage
haml_data = <<EOF
%html
%head
%title Big bang
%body
%p Haml content
= import_textile("<p>*Textile content*</p>", {}, {:xhtml => true})
%p some more haml content
EOF
puts Haml::Engine.new(haml_data).render
/lasso
> > /lasso- Dölj citerad text -
>
> - Visa citerad text -