<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body>
<div style="font-family:sans-serif"><div style="white-space:normal">
<p dir="auto">On 10 Oct 2019, at 20:49, Dru Kepple wrote:</p>
</div>
<div style="white-space:normal"><blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px"><p dir="auto">Let's suppose I have a command written in Ruby, that is outputting to HTML<br>
in a new window.<br>
<br>
Is there a way to create a link in the HTML output that, when clicked, will<br>
actually execute a Ruby function that I define in the command?</p>
</blockquote></div>
<div style="white-space:normal">
<p dir="auto">Not functions from your command, but you can have JavaScript call ruby scripts, so you would have to create an external script (in the <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">Support/</code> folder of the bundle) and then provide argument when calling this script, as to what function it should execute.</p>
<p dir="auto">The documentation is rather sparse: <a href="https://macromates.com/textmate/manual/html-output#javascript-api" style="color:#3983C4">https://macromates.com/textmate/manual/html-output#javascript-api</a></p>
<p dir="auto">Basically you can do <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7"><script>TextMate.system(«command»)</script></code> in your HTML output to call <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">«command»</code>.</p>
<p dir="auto">We have a few examples of this, for example ⌃H in a ruby file on a word will lookup documentation (<code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">ri</code>) for that word, and there will be links in the output which calls <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">ri</code> again.</p>
<p dir="auto">The script for this is here: <a href="https://github.com/textmate/ruby.tmbundle/blob/master/Support/bin/linked_ri.rb" style="color:#3983C4">https://github.com/textmate/ruby.tmbundle/blob/master/Support/bin/linked_ri.rb</a></p>
</div>
</div>
</body>
</html>