A Textile Filter for BBEdit?

Published 7 years, 10 months ago

A few days back I tweeted a request for a Textile filter for BBEdit, which is one of those things people have asked for over the years but has never actually appeared.  There’s been a Markdown filter since forever, but since I find myself on Basecamp a lot for business reasons and Basecamp uses Textile I’d really prefer to stick to one syntax instead of constantly confusing myself by switching between two similar syntaxes.

(And I prefer to use BBEdit because I like it a lot, know it well, and have no compelling reason to switch.  Please take any thoughts of text-editor snobbery or flamewars elsewhere.)

In response, the mighty Arlen Walker told me how to install Xcode, the Text::Textile module, and a short Perl script to drop into  ~/Library/Application Support/BBEdit/Unix Support/Unix Filters.  I did that, and it all worked, but I was unhappy with the <span class="caps"> that default Textile litters all over.  I tried to disable it, failed, tweeted for help, and was contacted by the incredible Brad Choate (who wrote the Text::Textile module!).

The upshot of all this is that Brad not only told me how to disable the spans, but how to convert Textile to a standalone BBEdit filter that, so far as I can tell, shouldn’t require installation of either Xcode or Text::Textile.  I’m pretty sure about this, but since I’ve already installed Text::Textile I can’t be entirely certain.  Who wants to test it out?

All you have to do is download TextileSA_pl.zip, unzip it, and drop the Perl script into ~/Library/Application Support/BBEdit/Unix Support/Unix Filters.  Once you do that, it should immediately become available in BBEdit, even if BBEdit is already running.  (At least that’s what happens in BBEdit 9.x.)  Here’s a test file to Texile-ize if you’re so inclined:

h1. Testing the BBEdit Textile filter

This is _awesome_!  "Arlen":http://theodicius.net/ and "Brad":http://bradchoate.com/ are the *bomb*.

There’s a bug at the moment that means double-quote marks don’t get smart-encoded, but Brad’s aware of it and plans to fix it.  Also, this does a straight Textile run with nothing disabled, so it will in fact still litter <span class="caps"> around any sequence of uppercase letters (like those in, say, “BBEdit”).  If you can’t stand that even during testing, open up TextileSA.pl and insert the following after line 2312:

my $css_flags = $textile->css();
$css_flags->{'class_caps'} = '';
$textile->css($css_flags);

If you don’t mind (or even like) those spans, then of course you can slip that part.

The “SA” in TextileSA.pl stands for “StandAlone”, by the way.  I’ll drop that once I’m sure this actually works and pass it along to the BBEdit gang.


  1. Yes, it works. Just entered your sample text and it does what’s expected.

  2. I believe this worked for me. Installed while running BBedit, opened new doc and used your sample text. Result: http://pastebin.com/ir5HKLRr

  3. I’ve been using Textile in BBEdit for a while now using a shell script linked to the original classTextile.php, but this made me get round to spending two minutes putting this baby together: http://gist.github.com/621230

    Just drop it in your Unix filters folder with the name ‘Textile’ (or, indeed, whatever you choose to name it) and it’ll work. This has the advantage of using the original Textile, which means you’ll get the same result as if you plugged your input right into Textpattern.

  4. The test example worked fine in BBEdit 8.2.6.

    I just tried it on the sample text from the Textile page on Textism, and it threw errors on lines 1557 – 1558 (same error message):

    ~/Library/Application Support/BBEdit/Unix Support/Unix Filters/TextileSA.pl:1557:
    Use of uninitialized value in string eq <> line 1.

    The relevant code on these lines is:


    $w = '' if $w eq '*';
    $h = '' if $h eq '*';

    Having said all that: the output looks okay, and it’s a bit late to go over it with a finer-toothed comb (esp. since it could just be a quirk of my older version of BBEdit).

    Regards,
    Kurtis

  5. Nice. This is also working in TextWrangler.

  6. […] Eric Meyer Go to the source […]

  7. sorry to be such a dweeb… but how exactly can i use this plugin with BBedit. i have a Textpattern site and it would be great to use BBedit as my editor for this.

  8. […] found a reasonably good article about how to add Textile to BBEdit but the explanations aren't very clear and one of the download links is broken and the other […]

  9. The link is broken
    http://meyerweb.com/eric/tools/bbedit/TextileSA.pl.zip

    yields:
    Unfortunately, something has gone horribly wrong here at meyerweb. …

  10. So I see, Richard. Problem is, I can’t figure out why. Other .zip files download fine, and the permissions on both the file and its directory seem fine. Renaming the file didn’t help either. I’m genuinely at a loss.

  11. Fixed! I think what was happening was the server was trying to execute the file as a Perl script instead of download it as a zip file, so I renamed it to ‘TextileSA_pl.zip’ instead of ‘TextileSA.pl.zip’. Thanks for the heads-up!

  12. Thank you Eric, I downloaded the file OK.
    I added it as a text filter to TextWrangler and it worked great!
    I appreciate your effort in making this script available

Leave a Comment

Management reserves the right to edit or remove any comment, especially when abusive or irrelevant to the topic at hand. HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <em> <i> <q cite=""> <s> <strong> <pre class=""> <kbd>


Comment Preview

If you're satisfied with what you've written, then go ahead...