meyerweb.com

Skip to: site navigation/presentation
Skip to: Thoughts From Eric

A Textile Filter for BBEdit?

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.

12 Responses»

    • #1
    • Comment
    • Mon 11 Oct 2010
    • 1644
    lloyd dunn wrote in to say...

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

    • #2
    • Comment
    • Mon 11 Oct 2010
    • 1701
    Tanya wrote in to say...

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

    • #3
    • Comment
    • Mon 11 Oct 2010
    • 1717
    David Kendal wrote in to say...

    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
    • Comment
    • Tue 12 Oct 2010
    • 0204
    Kurtis wrote in to say...

    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
    • Comment
    • Tue 12 Oct 2010
    • 0259
    Georg Portenkirchner wrote in to say...

    Nice. This is also working in TextWrangler.

    • #6
    • Pingback
    • Tue 12 Oct 2010
    • 0835
    Received from A Textile Filter for BBEdit? | Webdesigninformer.com

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

    • #7
    • Comment
    • Tue 12 Oct 2010
    • 1419
    walter wrote in to say...

    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
    • Pingback
    • Tue 8 Nov 2011
    • 0809
    Received from Textile Editing on OS X: BBEdit, iTextile, MarkMyWords | Foliovision

    […] 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
    • Comment
    • Thu 6 Dec 2012
    • 1747
    Richard Anderson wrote in to say...

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

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

    • #10
    • Comment
    • Thu 6 Dec 2012
    • 2320
    Eric Meyer wrote in to say...

    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
    • Comment
    • Fri 7 Dec 2012
    • 1036
    Eric Meyer wrote in to say...

    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
    • Comment
    • Fri 7 Dec 2012
    • 1052
    Richard Anderson wrote in to say...

    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

Line and paragraph breaks automatic, e-mail address required but never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



Remember to encode character entities if you're posting markup examples! Management reserves the right to edit or remove any comment—especially those that are abusive, irrelevant to the topic at hand, or made by anonymous posters—although honestly, most edits are a matter of fixing mangled markup. Thus the note about encoding your entities. If you're satisfied with what you've written, then go ahead...


October 2010
SMTWTFS
July November
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Sidestep

Feeds

Extras