[TxMt] Re: Pasting styled text into buffer's syntax

Steve King sking at arbor.net
Mon Feb 28 16:02:09 UTC 2011


On 2011-02-26 17:48, Turadg Aleahmad wrote:
> Is it possible for a Textmate bundle to capture the paste and 
> transform the styled text to the syntax of the current buffer? E.g. 
> styled text "This is bold and this has a link" would paste into a 
> Markdown doc as "This is **bold** and this has a 
> [link](http://example.com)" and into an HTML doc as "This is 
> <b>bold</b> and this has a <a href='http://example.com/'>link</a>".

Very interesting suggestion. I see no reason why it wouldn't be possible 
for a bundle, so long as you could figure out how to access the 
clipboard.  /usr/bin/pbpaste has an option to return RTF that was 
previously copied, but when I tried copying formatted text from Text 
Edit, pbpaste would only give me the plain ASCII.  If you're lucky 
you'll be able to find a pre-built clipboard module for your favorite 
scripting language, or at worst you'd have to compile some C or 
Objective-C code to access the system APIs. Once you got the raw 
clipboard bytes you'd just have to parse the RTF and output it as the 
appropriate markup for the current document type.

Sounds cool. Let us know when it's done. :-)

-- 
Steve King
Sr. Software Engineer
Arbor Networks
+1 734 821 1461
www.arbornetworks.com <http://www.arbornetworks.com/>




More information about the textmate mailing list