[TxMt] Dynamically including grammar patterns.

Matthew Schinckel matt at schinckel.net
Tue Jan 10 13:34:32 UTC 2012


Looking at the post http://blog.macromates.com/2011/format-strings/, I was 
excited by the idea of being able to dynamically include other patterns 
into the matched scope.

However, it doesn't quite work.  I have in my Jekyll grammar, a pattern:

{
  begin = '\{% highlight (html) %\}';
  end = '\{% endhighlight %\}\n';
  name = 'source.$1.embedded.html.markdown';
  patterns = (
    {  include = 'text.html.basic'; },
  );
},


This is handled fine: it matches as intended, and puts the html into the 
name as expected.

However, I can't use the same trick in the included patterns:

{
  begin = '\{% highlight (html) %\}';
  end = '\{% endhighlight %\}\n';
  name = 'source.$1.embedded.html.markdown';
  patterns = (
    {  include = 'text.$1.basic'; },
  );
},

In this case, the syntax highlighting of the embedded code is not applied.

I know this is a simple example: I am hoping to be able to extend it to 
automatically match whatever type of file I want highlighted (python, js, 
ruby, html, css, ... you get the picture).

Regards,

Matt.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20120110/964931e5/attachment.html>


More information about the textmate mailing list