Textile your textareas with Greasemonkey

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.

Published by

9 thoughts on “Textile your textareas with Greasemonkey”

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. That’s awesome!

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

  6. 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.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.