-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi,
I've been poking again around in the bundle editor.(Yes the Bundle editor is very addictive) The default command : TextMate > create HTML from selection is very convenient.
However, I had the Idea, to have the same thing as a drag command (without the styles), so one could just write a post and drag the code snippets in from The drawer ( file extension code of something)
I tried to replace the variable content of TM_SELECTED_TEXT with something like :
`cat "TM_DROPPED_FILE"`, but it doesn't output anything just the HTML tags until the pre tags.
Could it be done easily, using the same requires in RUBY.
That way, one could just write along, while dragging the code in, without loosing focus of the document window.
Wouldn't that be nice ?
Any Ideas ?
regards, marios
On 17. Nov 2006, at 12:33, marios wrote:
I've been poking again around in the bundle editor.(Yes the Bundle editor is very addictive) The default command : TextMate > create HTML from selection is very convenient.
However, I had the Idea, to have the same thing as a drag command (without the styles), so one could just write a post and drag the code snippets in from The drawer ( file extension code of something)
I tried to replace the variable content of TM_SELECTED_TEXT with something like :
`cat "TM_DROPPED_FILE"`, but it doesn't output anything just the HTML tags until the pre tags.
Could it be done easily, using the same requires in RUBY.
Could you post what you tried?
If I understand you, you want to have the contents of a file inserted, when you drag it to the editor window. But does it not already do that?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Allan Odgaard wrote:
On 17. Nov 2006, at 12:33, marios wrote:
I've been poking again around in the bundle editor.(Yes the Bundle editor is very addictive) The default command : TextMate > create HTML from selection is very convenient.
However, I had the Idea, to have the same thing as a drag command (without the styles), so one could just write a post and drag the code snippets in from The drawer ( file extension code of something)
I tried to replace the variable content of TM_SELECTED_TEXT with something like :
`cat "TM_DROPPED_FILE"`, but it doesn't output anything just the HTML tags until the pre tags.
Could it be done easily, using the same requires in RUBY.
Could you post what you tried?
If I understand you, you want to have the contents of a file inserted, when you drag it to the editor window. But does it not already do that?
I haven't updated my Bundles recently, so in short, if I want just to insert the contents of a file, I could create a drag command, give it a file type of code and with: cat "$TM_DROPPED_FILE" it will insert the content.
The Idea though was to not only insert the code snippet, but also html-ify it with the TextMate > create HTML from selection/ Document command.
Taking the original Code, and creating a new drag command, i tried something like this:
#!/usr/bin/env ruby -rjcode -Ku require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/doctohtml.rb" require "#{ENV['TM_SUPPORT_PATH']}/lib/progress.rb" code=`cat "$TM_DROPPED_FILE"` unit = ENV.has_key?('CODE') ? 'selection' : 'document' TextMate.call_with_progress(:message => "Creating HTML version of #{unit}?") do print document_to_html( STDIN.read, :include_css => !ENV.has_key?('CODE') ) end
(which is probably wrong)
The default command would use a selection or Document, HTML-ify the input and output a new document with the styles and HTML.
The Idea behind this, is that you could maintain your code snippets nicely organized in a Folder, and once needed just drag them in, while you write an article about how something is done with code examples, using your preferred CMS.
I'd also omit the output of the style rules, and just create a new style sheet for the language I need and put the style reference in my header.
This is based on Aaron Quints original Idea.
regards, marios
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
marios wrote:
Allan Odgaard wrote:
On 17. Nov 2006, at 12:33, marios wrote:
I've been poking again around in the bundle editor.(Yes the Bundle editor is very addictive) The default command : TextMate > create HTML from selection is very convenient.
However, I had the Idea, to have the same thing as a drag command (without the styles), so one could just write a post and drag the code snippets in from The drawer ( file extension code of something)
I tried to replace the variable content of TM_SELECTED_TEXT with something like :
`cat "TM_DROPPED_FILE"`, but it doesn't output anything just the HTML tags until the pre tags.
Could it be done easily, using the same requires in RUBY.
Could you post what you tried?
If I understand you, you want to have the contents of a file inserted, when you drag it to the editor window. But does it not already do that?
I haven't updated my Bundles recently, so in short, if I want just to insert the contents of a file, I could create a drag command, give it a file type of code and with: cat "$TM_DROPPED_FILE" it will insert the content.
The Idea though was to not only insert the code snippet, but also html-ify it with the TextMate > create HTML from selection/ Document command.
Taking the original Code, and creating a new drag command, i tried something like this:
#!/usr/bin/env ruby -rjcode -Ku require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/doctohtml.rb" require "#{ENV['TM_SUPPORT_PATH']}/lib/progress.rb" code=`cat "$TM_DROPPED_FILE"` unit = ENV.has_key?('CODE') ? 'selection' : 'document' TextMate.call_with_progress(:message => "Creating HTML version of #{unit}?") do print document_to_html( STDIN.read, :include_css => !ENV.has_key?('CODE') ) end
(which is probably wrong)
CORRECTION: the code variable name uppercase, but it wouldn't work either way: The HTML that it outputs is just the normal wrapper code:
</style> </head>
<body><pre class="textmate-source texari"></pre> </body> </html>
The default command would use a selection or Document, HTML-ify the input and output a new document with the styles and HTML.
The Idea behind this, is that you could maintain your code snippets nicely organized in a Folder, and once needed just drag them in, while you write an article about how something is done with code examples, using your preferred CMS.
I'd also omit the output of the style rules, and just create a new style sheet for the language I need and put the style reference in my header.
This is based on Aaron Quints original Idea.
regards, marios
______________________________________________________________________ For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On 18. Nov 2006, at 20:33, marios wrote:
[...] The Idea though was to not only insert the code snippet, but also html-ify it with the TextMate > create HTML from selection/ Document command.
Taking the original Code, and creating a new drag command, i tried something like this: [...]
Okay, that is not possible -- the Create HTML From Document / Selection gets the document / selection as it is parsed by TextMate, you can’t currently invoke the TM parser on arbitrary files.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Allan Odgaard wrote:
On 18. Nov 2006, at 20:33, marios wrote:
[...] The Idea though was to not only insert the code snippet, but also html-ify it with the TextMate > create HTML from selection/ Document command.
Taking the original Code, and creating a new drag command, i tried something like this: [...]
Okay, that is not possible -- the Create HTML From Document / Selection gets the document / selection as it is parsed by TextMate, you can’t currently invoke the TM parser on arbitrary files.
Ok, I understand. I have cobbled together a workaround, I wrote about it here: http://www.consking.com/delyriumlab/prettify-your-code (I didn't think about the white space though, so I have to modify the macro)
regards, marios