">'); win.document.writeln(''); win.document.writeln(''); }
 

The Indefinite Article.

Friday, April 22, 2005

Safari's Table-Copying Behavior

NSLog(); - Safari's Table-Copying Behavior

This has long been an annoyance for me. However, the not bad thing is that the string is regularly formatted and can easily be changed to something useful with regular expressions. At first, I made two BBEdit Text Factories; one changes the Safari copied table string into tab delimited and the other changes it into an html table.

I continued thinking about this topic and wrote a cleaner shell script for the Safari table to tabs problem:


#!/bin/sh
pbpaste | perl -p -e 's/(\r|\n)/\r\t/gi' | perl -p -e 's/\r\t\r\t/\r/gi' | perl -p -e 's/\r\t/\t/gi' | pbcopy

I'm certain that someone better at Perl can rewrite this to be shorter. I wrote this one because I was copying Safari tables into a Windows XP device over RDC and pasting into BBEdit, executing the text factory, and copy/pasting into RDC, which was a pain. I have plugged the script into Quicksilver, so that the workflow is copy, QS command (command space for me, then type ta to select the script and return to execute), then paste. No more shifting between three apps to get what I want!

0 Comments:

Post a Comment

<< Home