Textile your textareas with Greasemonkey

11 March, 2005

First of all, the link to the script: Textile your textareas with pure JavaScript.

Roberto De Almeida has posted a Greasemonkey script that makes all textareas textilable which works by injecting a button after your textarea which sends its contents off to his public PyTextile service and then replaces your contents with the parsed results, which means that although you have the full power of the latest version of PyTextile at your fingertips, it can be a little slow to respond.

But of course, Textile has been ported to JavaScript, so here’s a script which does the Textile transformation locally. It’s more limited than Roberto’s version, but still covers most of what you might want to do, like headings, lists, images, text-styling (bold and so on), but no tables and the more complex elements.

It’s based around Roberto’s script and uses Jeff Minard’s SuperTextile for the actual transormation. There’s currently something slightly wrong with it as it sometimes takes a few seconds to run through the final regexes, but I’ll probably just live with it.

See other posts tagged with general and all posts made in March 2005.


15 March, 2005 at 08:38

This guy has an interesting comment on your textile stuff – namely that rework is next to impossible.

Do you think it would be useful to inject a second textarea that you put your textile stuff in that updates the original text area with the html-ed text?

Still won’t help you after you’ve hit post but it might be better than now.

15 March, 2005 at 16:15

I’m the griper Gareth references.

Dual textareas, one for input, the other for the output, would help things somewhat. More compact would be to have a button that toggles between the transformed and untransformed text. However, I’m not sure it would be enough better to make it worthwhile for my sloppy and impatient self.

What might be cool is to store the original text with some persistance and have a button for recovering it.
If it persisted within a browswer session, it would be useful for thos e situations when I’m making a one-off entry in some system I have no control over (like this one), that I might want to preview, but I’m unlikely and/or unable to return to later and edit.

If it persisted across browswer sessions, that would open it to a wider range of uses. From my point of view, I’m not sure how much utility it adds, since I don’t enter much text into systems I don’t control that I might want to return to and edit later. On the otherhand, someone using Blogger might.

I don’t know much about javascript, but as I recall, its possible to do something like this as far as storing the text(I think SquirrelMail uses it to store drafts).

Ideally the Greasemonkey script would have some context awareness and only present the cached source-text relevant to the form in question.

This could be accomplished a few ways.

1) URL matching, but URLs can change.
2) Hostname matching
3) Matching of the contents of the textarea with a transformed version of the cached text (with allowances for differences in whitespace & captitalization).

#3 is probably the highest precision.

16 March, 2005 at 20:39

Well, let’s not get carried away 🙂

You’re right though, the ability to keep editing the original textile text would be really good (especially seeing as I’ve just fallen foul of it myself!).

I’ll definitely give it a go.

Mike Sugarbaker
24 June, 2005 at 00:43

I’ve extended this to translate Textile to BBCode or MediaWiki markup as well as HTML. It’s still only one way, however. Here it be: Lingua Franca.

24 June, 2005 at 07:41

That’s awesome!

I have a version which keeps the original text, I’ll clean it up and update the main script.

07 November, 2005 at 22:46

Hi Tiago, thanks for this. I’ve been meaning to release a more powerful rewrite of the greasemonkey script for about six months now, hopefully this should prompt me into it; I’ll try and get a new version out in the next few days.

26 April, 2007 at 22:13


should be bold, no?