[TxMt] [ANN] Theme to CSS stylesheet, document to HTML/CSS commands

Brad Choate bchoate at gmail.com
Mon May 8 02:31:17 UTC 2006


Have you ever wanted to publish your source code with your syntax  
highlighting intact? That is, formatted the way that TextMate sees  
it?  Well, thanks to a recent update to TextMate[1], it's now  
possible.  I've created two commands that are in the TextMate  
subversion repository[2] that are in the Experimental bundle:

Create HTML from Document / Selection:
	This command will take your entire document and create a new one  
that is an HTML file which recreates the view of your document as  
TextMate renders it.  It also preserves the colors that you're using  
as your current TextMate theme, since it generates the CSS from your  
theme file.  If you have a selection, this command will only output a  
'<pre>' block for that section (instead of generating a full HTML  
document plus stylesheet).

Create CSS from Theme:
	This command creates a new CSS document that is based on your  
current theme.

So, what is this good for? Well, if you want to publish snippets of  
code, nicely highlighted, but don't want to create images.  Besides,  
textual examples are better than images since they're searchable.   
So, you could create the CSS rules based on your theme, then add it  
to your existing site's stylesheet.  Then, you can invoke the "Create  
HTML..." command to create the HTML.

Why did I do this? There are many syntax highlighting solutions out  
there (indeed, TM itself has a few commands that do this kind of  
thing, but they don't reliably reproduce the document the way TM sees  
it). But this one leverages the document parsing TM does-- and  
therefore, it works with any language definition that is in your  
TextMate bundle set.  It also doesn't require any additional software  
to be installed.

Please report any errors you find to me. And thanks again to Allan  
for adding support necessary to do this.

Brad Choate
http://bradchoate.com/


[1] - Release 948's "One can now access the document as parsed by  
TextMate." new feature. So these commands require that release or later.
[2] - http://anon:anon@macromates.com/svn/Bundles/trunk/Bundles/ 
Experimental.tmbundle/Commands/




More information about the textmate mailing list