From turadg@cmu.edu Sat Feb 26 22:49:03 2011 From: Turadg Aleahmad To: textmate@lists.macromates.com Subject: [TxMt] Pasting styled text into buffer's syntax Date: Sat, 26 Feb 2011 17:48:40 -0500 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1247337710073156221==" --===============1247337710073156221== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sometimes I have styled text on the clipboard that I would like to put into a Markdown or HTML document. When I paste into any document, it appears as plain text stripped of any style info. 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 bold and this has a link". If this isn't possible, is anyone else interested in having this feature in Textmate or developing a system service for it? Turadg Aleahmad PhD student , HCII --===============1247337710073156221== Content-Type: text/html Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="attachment.htm" MIME-Version: 1.0 U29tZXRpbWVzIEkgaGF2ZSBzdHlsZWQgdGV4dCBvbiB0aGUgY2xpcGJvYXJkIHRoYXQgSSB3b3Vs ZCBsaWtlIHRvIHB1dCBpbnRvIGEgTWFya2Rvd24gb3IgSFRNTCBkb2N1bWVudC4gV2hlbiBJIHBh c3RlIGludG8gYW55IGRvY3VtZW50LCBpdCBhcHBlYXJzIGFzIHBsYWluIHRleHQgc3RyaXBwZWQg b2YgYW55IHN0eWxlIGluZm8uPGRpdj48ZGl2Pjxicj48L2Rpdj48ZGl2PklzIGl0IHBvc3NpYmxl IGZvciBhIFRleHRtYXRlIGJ1bmRsZSB0byBjYXB0dXJlIHRoZSBwYXN0ZSBhbmQgdHJhbnNmb3Jt IHRoZSBzdHlsZWQgdGV4dCB0byB0aGUgc3ludGF4IG9mIHRoZSBjdXJyZW50IGJ1ZmZlcj8gRS5n LiBzdHlsZWQgdGV4dCAmcXVvdDtUaGlzIGlzIGJvbGQgYW5kIHRoaXMgaGFzIGEgbGluayZxdW90 OyB3b3VsZCBwYX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I+PC9k aXY+PC9kaXY+Cg== --===============1247337710073156221==-- From sking@arbor.net Mon Feb 28 16:02:19 2011 From: Steve King To: textmate@lists.macromates.com Subject: [TxMt] Re: Pasting styled text into buffer's syntax Date: Mon, 28 Feb 2011 11:02:09 -0500 Message-ID: <4D6BC701.8030207@arbor.net> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6520747933799389796==" --===============6520747933799389796== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 > bold and this has a link". 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 --===============6520747933799389796==--