The Accidental Rubyist

invalid byte sequence in UTF-8

some more testing of a script that will do the code formatting

leave a comment »

I have hacked a script which converts the selected text in Ecto to the following formatted text.

while (<>) {
 $text .= $_;
}
# procedural usage
my $html = textile($text);
#print $html; <---- this would get printed in a dialog box
open ( FILE, ">$entryfile" ) or die;
print FILE $html;
close FILE;

[Update: If you look carefully, syntax highliting done by the hack above is not as comprehensive as the one done to textile.pl in this post. This is because in those cases, since the entire file went through the filter, the filter knew the programming language and could thus do a language specific highlighting. In the case of highlighting code within ecto and running the script, the filter invoked does not know the language. That can be further taken care of by examining the first line of the sample, and determining language from a <code>”#!/bin/env ruby”</code> like statement.]

However, before i fall asleep let me apologize. I notice that one entry of mine posted in the morning (inter.rb) seems to have the code intact. In that case, I pasted the code into the rich text editor. It did the required conversions. This appears to work fine.

It is only when i pasted the code into the HTML editor, in order to put the PRE and CODE tags, that i began to lose characters. So a lot of testing and time has gone waste. But i do have a neat hack ready now, and I have learned a couple of things about a couple of things.
I will share this hack tomorrow morning.

Back to sleep after a bit of reading The Northern Light. Oh, did I mention that I have mapped ^B and ^I to do bold-facing and italicizing.

COOL !!!

Advertisements

Written by totalrecall

February 28, 2007 at 11:13 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: