Hi,
I have a small question.
If I write a command which should do something with highlighted text of my current document I can specify within the myCommand.tmCommand the plist key 'inputFormat' as 'xml' (e.g. Create HTML from Document). OK.
But now I want to write a script which should be called by the Web Preview option 'Pipe text through'. Here I don't get the content of my current document with xml markups for syntax highlighting.
Is there a way without changing TM's source code to receive these xml markups?
Many thanks in advance !!!!!!!!!! ;)
Hans
---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.
Don't use the "Pipe text through" option. Instead, create a new command, scoped so it will only be triggered within the context you want, with the key shortcut ⌘⌥⌃P (that's cmd-opt-control-P). The output format should be View As HTML. This way you can press ⌘⌥⌃P and get what appears to be a web preview, but is really the results of your command.
For examples, look at how Markdown does this.
On Dec 5, 2006, at 12:09 PM, Hans-Joerg Bibiko wrote:
I have a small question.
If I write a command which should do something with highlighted text of my current document I can specify within the myCommand.tmCommand the plist key 'inputFormat' as 'xml' (e.g. Create HTML from Document). OK.
But now I want to write a script which should be called by the Web Preview option 'Pipe text through'. Here I don't get the content of my current document with xml markups for syntax highlighting.
Is there a way without changing TM's source code to receive these xml markups?
Many thanks in advance !!!!!!!!!! ;)
Thanks,
Don't use the "Pipe text through" option. Instead, create a new command, scoped so it will only be triggered within the context you want, with the key shortcut ⌘⌥⌃P (that's cmd-opt-control-P). The output format should be View As HTML. This way you can press ⌘⌥⌃P and get what appears to be a web preview, but is really the results of your command.
This I did before and it works perfectly.
But my point is the nice Web Preview option "Refresh after change".
That means that while typing my document the transformed Web Preview shows the latest changes. Of course I always can type some short cut to get this via a command, but "Refresh after change" would be more comfortable ;)
On the other hand, maybe there is a way to call a Bundle's command like a cron job, i.e. a command which will be execute e.g. each 0.5s.
Thanks in advance
-Hans
[...] But my point is the nice Web Preview option "Refresh after change".
That means that while typing my document the transformed Web Preview shows the latest changes. Of course I always can type some short cut to get this via a command, but "Refresh after change" would be more comfortable ;)
On the other hand, maybe there is a way to call a Bundle's command like a cron job, i.e. a command which will be execute e.g. each 0.5s.
OK I found a solution. It is a kind of an hack but at least it works.
The idea:
- write a bash script which - execute via osascript a TM command (or commands ;) ) to write the content with syntax markups to disk - transform this temp file (e.g. like doctohtml.rb) - pipe it to Web Preview - put this bash script in TM_SUPPORT_PATH/bin - type this script in 'Pipe text through' within Web Preview Options
and it works.
BTW Doing so you can do some nice things, e.g. - call Bundle commands from a Bundle command via osascript - run a Bundle command as daemon (or with Web Preview 'pipe text through') e.g. for automatic 'Completion' while typing without pressing ESC (This I tried out and it works quite good if you fine-tune the refresh rate and switch off your loudspeaker ;)
I know it is only a hack and has of course limitations (esp. for speed) but ... my tiny problem is solved ;)
Best
-Hans