[TxMt] Dynamic includes in language grammars

Tyson Tate tyson at tysontate.com
Tue May 8 22:08:53 UTC 2012


I'm updating my Markdown bundle to better handle GitHub-style fenced code blocks like so:

	```ruby
	foo = { bar: true }
	```

The grammar is simple enough for one language:

	ruby_block = {
		begin = '^```ruby.*$';
		end = '^```.*$';
		patterns = ( { include = 'source.ruby'; } );
	};

However, I'd like to support any language. I tried the following, but it doesn't appear to work (and I'm not sure why):

	code_block = {
		begin = '^```(\w+).*$';
		end = '^```.*$';
		patterns = ( { include = 'source.\1'; } );
	};

Is something similar possible / supported?

Thanks!

-Tyson


More information about the textmate mailing list