1

I am trying to highlight a custom language in TextMate. However, the following definition does not highlight PHP insertions:

{   scopeName = 'source.serpent';
    fileTypes = ( 'serpent' );
    patterns = (
        {   begin = '<\?';
            end = '\?>';
            patterns = ( { include = 'source.php'; } );
        },
    );
}

What can be the reason?


Update

Well, I was too naive to expect that the above definition will refer to the PHP language definition.Apparently, in order to highlight PHP insertions, one have to copy a significant part of the PHP language rules to the new language. And if I would like to use Ruby insertions as well, then it gets really messy.

So, I would like to ask if it is possible to REFER to (NOT to copy!) PHP or Ruby definitions from my new language (serpent) definition. It would make it clear and reduce duplication.


Update2

Apparently, it is an issue of PHP only. The following language definition highlights Ruby and Serpent languages in my text, but not PHP insertions! What the hell is wrong here?

{   scopeName = 'source.phpruby.serpent';
    fileTypes = ( 'serpent', 'serpent.php', 'serpent.erb' );
    patterns = (
        {   begin = '<\?(php|=)?';
            end = '\?>';
            patterns = ( { include = 'source.php'; } );
        },
        {   begin = '<%';
            end = '%>';
            patterns = ( { include = 'source.ruby'; } );
        },
        {   include = 'source.serpent'; },
    );
}

1 Answer 1

0

On Fri, Jul 9, 2010 at 08:02, Allan Odgaard wrote:

We made the PHP grammar itself match the construct, so with your grammar, those bits have been consumed by the including grammar, and the included PHP grammar will therefor be a no-op.

The reason we made it this way was so that the PHP grammar can sort of work when used as the root grammar, since lots of users insist on using it that way, despite our efforts¹ to educate ;)

¹ http://wiki.macromates.com/Troubleshooting/PHPSyntaxHighlight

With the help of the God, I understood my mistake and was able to make a working (at least highlighting!) definition:

{   scopeName = 'source.phpruby.serpent';
    fileTypes = ( 'serpent', 'serpent.php', 'serpent.erb' );
    patterns = (
        {   begin = '<\?(php|=|)';
            end = '\?>';
            include = 'source.php';
        },
        {   begin = '<%';
            end = '%>';
            patterns = ( { include = 'source.ruby'; } );
        },
        {   include = 'source.serpent'; },
    );
}
1
  • There was a not working code for a short while, but then it has been fixed.
    – Andy
    Jul 9, 2010 at 18:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .