<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:12pt"><div><br></div><div style="font-family: arial,helvetica,sans-serif; font-size: 12pt;">Hi all,<br><br>Thanks for the two replies. highlight is a cool program I found here,<br><br><span><a target="_blank" href="http://www.andre-simon.de/doku/highlight/en/highlight_io.html">http://www.andre-simon.de/doku/highlight/en/highlight_io.html</a></span><br><br>I made an attempt to create a TM command for this, and it seems to work without the need for a temp directory,<br><br>highlight -H --syntax R --inline-css --fragment --enclose-pre --style print `$TM_SELECTED_TEXT` | pbcopy<br><br><br>It seems to work, albeit with some warning (seems to be attempting at interpreting the code of TM_SELECTED_TEXT) but since I simply discard the output and use the clipboard it's fine
for my purpose.<br><br><br><span>It's a small world JiHO! --- I'm hoping to use this shortcut to post R code on the new ggplot Wiki (<a target="_blank" href="http://ggplot2.wik.is">http://ggplot2.wik.is</a>).</span><br><br>Cheers,<br><br>baptiste<br><br><div style="font-family: arial,helvetica,sans-serif; font-size: 13px;">----------------------------------------------------------------------<br><br>Message: 1<br>Date: Fri, 8 May 2009 10:08:01 -0400<br>From: JiHO <<a ymailto="mailto:jo.lists@gmail.com" href="mailto:jo.lists@gmail.com">jo.lists@gmail.com</a>><br>Subject: [TxMt] Re: hightlight macro<br>To: TextMate users <<a ymailto="mailto:textmate@lists.macromates.com" href="mailto:textmate@lists.macromates.com">textmate@lists.macromates.com</a>><br>Message-ID: <<a ymailto="mailto:7ADEBAA5-A929-4FB6-9782-8C4CEA7BE126@gmail.com"
href="mailto:7ADEBAA5-A929-4FB6-9782-8C4CEA7BE126@gmail.com">7ADEBAA5-A929-4FB6-9782-8C4CEA7BE126@gmail.com</a>><br>Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes<br><br>On 2009-May-07 , at 05:21 , baptiste auguie wrote:<br><br>> I'm using a command line to create a html snippet with embedded css <br>> to post on a Wiki. At the moment I run,<br>><br>> highlight test.r -H --inline-css --fragment --enclose-pre -- <br>> style print | pbcopy<br>><br>> on the command line. I'd like to create a macro in TM so that I can <br>> get the same processing applied to selected text in a document. I've <br>> never written any TM macro and I don't know Ruby (or bash for that <br>> matter). Would you be kind enough to help me out?<br><br>Apparently highlight (is that a command of your creation or something <br>else? It would help to know a little more about it)
takes a file as <br>argument. So the only ways to have it work on a selection are:<br>1- to modify highlight to accept either a file or some raw text from <br>standard input (or only raw text)<br>2- copy the current selection to a temporary document and feed that to <br>highlight<br><br>If 1, then you can use highlight with no argument and set TM to feed <br>it selection or document. If the new version can only be made to <br>accept raw text you can still use it independently this way:<br> cat doc.r | highlight -H -...<br><br>If 2, the command would look like<br><br> # create a temporary document (cleanly)<br> tmpDoc=$(mktemp)<br> # fill it with TM input (selection or doc)<br> cat > $tmpDoc<br> # feed it to highlight<br> highlight $tmpDoc -H -...<br><br><br>Otherwise, depending on the purpose of
these snippets, there are <br>plenty of online paste boards with syntax highlighting support for R, <br>and one is accessible from textmate (Paste selection online). You get <br>something like this:<br> <a href="http://pastie.textmate.org/private/epwkcdngtzljzkf1zxg" target="_blank">http://pastie.textmate.org/private/epwkcdngtzljzkf1zxg</a><br>with a link you can embed in other pages (and I guess also in a wiki). <br>I am also pretty sure I saw some that could output the html that is <br>displayed (with the colors etc.).<br><br>Hop that helps.<br><br>JiHO<br>---<br><a href="http://jo.irisson.free.fr/" target="_blank">http://jo.irisson.free.fr/</a><br><br><br><br></div></div></div><br>
</body></html>