[TxMt] TextMate Create HTML from Selection

marios tmtxpstuff at consking.com
Sat Nov 18 19:43:22 UTC 2006


-----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 at lists.macromates.com
(threading gets destroyed and the universe will collapse if you don't)
http://lists.macromates.com/mailman/listinfo/textmate

-----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

iD8DBQFFX2Ja8tSzPOYuZvQRAoJrAKCEOEYGVrCFfaHMVCs27QrptyJ64ACgwkpt
8ZCn/s6vhmzcFLePDSPm8to=
=VvCi
-----END PGP SIGNATURE-----



More information about the textmate mailing list