Neat trick: Embedding applescript source code in LaTeX

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Neat trick: Embedding applescript source code in LaTeX

Ramón Figueroa-Centeno
Aloha,

Here is a neat trick. You can embed in a link in LaTeX an applescript. When the link is clicked the Applescript Editor opens with the code inserted. Try the following,

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\href{applescript://com.apple.scripteditor?action=new\%26script=display\%20dialog\%20\%22hello\%22}{Click me!}
\end{document}

You can use a utility named ApplescriptHTML <http://homepage.mac.com/tkurita/scriptfactory/en/index.html> to do most of the conversion for you (it generates HTML so you have to escape % to \% for it to work in LaTeX).

I am adding similar functionality to my "TeXShop Webpage Helper" so we could embed TeX in links in web pages and PDFs that open in TeX. Imagine having a symbols list in a PDF or favorite snippets and clicking on a link and then having the code inserted into your current document or a new one. You do not have to worry about the encoding because I have already written a TeXShop macro that does all the ugly work: you select some text, run the macro and an encoded URL for the protocol texshop:// is placed in the clipboard. We could write live LaTeX manuals and tutorials for our students. Anyway I am geeked :)

Mahalo,

Ramón
Reply | Threaded
Open this post in threaded view
|

Re: Neat trick: Embedding applescript source code in LaTeX

Louis Talman

On Jun 3, 2010, at 7:12 PM, Ramón Figueroa-Centeno wrote:

> Here is a neat trick. You can embed in a link in LaTeX an applescript.

Sounds dangerous.  What if you get a document with a malicious script?


--Lou Talman
  Department of Mathematical & Computer Sciences
  Metropolitan State College of Denver

  <http://rowdy.mscd.edu/%7Etalmanl>




----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: http://email.esm.psu.edu/mac-tex/
List Archive: http://tug.org/pipermail/macostex-archives/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: http://email.esm.psu.edu/mailman/listinfo/macosx-tex

Reply | Threaded
Open this post in threaded view
|

Re: Neat trick: Embedding applescript source code in LaTeX

Ramón Figueroa-Centeno
Aloha,

No more dangerous than downloading software. Also, it does not run the script, it places it in the editor, it is up to you to read it and then decide if it is safe.

Now, that has been a concern of mine when developing "TeXShop Webpage Helper" and I decided that all it should do is allow a hyperlink to scroll around in an existing document (that is all it does right now) and later be able to insert stuff in a new document (in the current selection or a particular place), paste into a new document or into the clipboard. I would not never typeset, so it will not be more dangerous than downloading a TeX file and opening, today.

Ramón