It is time to upgrade your browser! This site looks and acts much better in a newer browser. Go TO THIS PAGE to find LINKS to all the major NEW BROWSERS. The links are at the bottom of the page under "What can I do?"

Or, you may keep reading this ugly page.


[splash image]

MTAA-RR » news » twhid » geek » use node js with bbedit text filters feature:

Nov 17, 2011

Use Node.js with BBEdit text filters feature

posted at 05:12 GMT by T.Whid in /news/twhid/geek

I was poking around the jQuery git repo the other day and noticed that they’ve started using Node for all their build scripts (I’m assuming, or maybe remembering faultily, that they were using Ant or Ruby for the build stuff previously). Makes sense: jQuery — make it 100% JavaScript, even down to the build scripts.

Then a little bulb went off in my head. “Oh yeah,” I thought to myself, “with Node one can now use JavaScript to write shell scripts.” (Duh!? I know.)

Later that day I found myself needing to de/unencode URIs to be used as URI components. “Simple,” I thought, “I’ll just use JavaScript’s decodeURIComponent and encodeURIComponent methods via Node and a BBEdit text filter.” But. Um. Turned out it wasn’t that simple (or maybe I’m just dumb).

Anyway, after a bit of head-scratching and digging around Node’s and BBEdit’s documentation, I got it working. The two scripts linked below are very simple, single-serving tools. You can run JavaScript’s encodeURIComponent with one and decodeURIComponent with the other. That’s it. One can imagine that it will now be very easy to port many useful JavaScript programs to be used as BBEdit text filters. JSLint or JSONLint come to mind.

To use the scripts you need to:
  1. have Node installed (there are instructions here (scroll down for OS X)),
  2. update the shebang line at the top of the script to point to your Node installation (if you’re not sure, type ‘which node’ at the command prompt in OS X’s terminal application),
  3. put the files in BBEdit’s text filters folder (prior to BBEdit 10 ‘text filters’ were called ‘unix filters’)
Have fun! permanent link to this post

MTAA-RR » news » twhid » geek » use node js with bbedit text filters feature

1997 - 2006 M.River & T.Whid Art Associates. Some Rights Reserved. is licensed under a Creative Commons License with the exception of Website Unseen titles which are covered by agreements with individual collectors and otherwise where noted.