The Accidental Rubyist

invalid byte sequence in UTF-8

ecto and Markdown

leave a comment »

#!/usr/bin/env ruby
# Markdown'ise things.
# Take Markdown markup on STDIN, and output HTML to STDOUT
require 'rubygems'
require 'bluecloth'
#print (BlueCloth.new STDIN.read).to_html
file = ARGV[0];
text = File.open(file,"r").readlines.join;
html = (BlueCloth.new text).to_html
File.open(file, "w").puts html;

I must first admit that since ecto supports a WYSIWYG editor therefore a script that does textile or markdown filtering does not make much sense. Also, there is the possibility of the confusion being created. Thus the textile and Markdown examples are more of examples of what can be done. A more practical example is the inter.rb given somewhere in the previous post.

Anyway, that said, the above example requires ruby, rubygems and the BlueCloth gem to be installed. If you are running Unix or Mac OS X (which you should be), you would have ruby. Install rubygems, and then install BlueCloth as:

sudo gem install BlueCloth

(sudo is required for OS X.)

Advertisements

Written by totalrecall

February 28, 2007 at 7:05 pm

Posted in ecto, Mac OS X, ruby

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: