[TxMt] TextMate Create HTML from Selection
marios
tmtxpstuff at consking.com
Sat Nov 18 19:33:15 UTC 2006
-----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 SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)
Comment: This might change in the future
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFX1/78tSzPOYuZvQRAjegAJ0WADK/dyvCi5KO2a1lnZzle3kReQCgzef4
nMlem6Oq+4aeGjfetsUjeRw=
=sBMo
-----END PGP SIGNATURE-----
More information about the textmate
mailing list