Hi. I've been trying to modify the HTML language so that it understands embedded Python code, as you find in a Kid template. For example:
<?python def shoe(potato): pass ?>
By default TextMate thinks it's PHP code (source.php.embedded.html).
I thought it would be pretty straightforward, and copied the chunk of config that appears to setup embedded ruby. I ended up with this, defined just beneath php-source:
python = { name = 'source.python.embedded.html'; begin = '(?:^\s*)<?python(?!.*?>)'; end = '?>(?:\s*$\n)?'; patterns = ( { name = 'comment.line.number-sign.ruby'; match = '#.*?(?=-?%>)'; }, { include = 'source.python'; }, ); };
However, when I click "Format" and "Test" in the Bundle Editor the text in my editor is still marked up as PHP. I removed all the PHP stuff to see if it was overriding the Python settings, but it didn't help.
What should I be doing for this?
Cheers...
On Sunday 18 December, Domenico Carbotta wrote:
move the mach before php and check if this works
Good idea. It didn't work though.
I did try this earlier, but when I clicked "Format" they were sorted alphabetically and python therefore came after php. I therefore suspect that the order isn't significant.
Removing the PHP stuff altogether didn't help either. I think there must be something missing from the rule.
python = { name = 'source.python.embedded.html'; begin = '(?:^\s*)<?python(?!.*?>)'; end = '?>(?:\s*$\n)?'; patterns = ( { name = 'comment.line.number-sign.ruby'; match = '#.*?(?=-?%>)'; }, { include = 'source.python'; }, ); };
That's a repository rule, you have to include it in the main grammar at some point. Look above and you'll see the php repository item included at some point.
http://macromates.com/textmate/manual/language_grammars.html#rule_keys
Provided that the python part of <?python is required it could be included in the default HTML syntax, PHP doesn't require the php so it catches <? ?>, but if this is before it it'd work.
In response to the later email, the order of repository items doesn't matter. But the order they are included in the syntax does matter.
On Saturday 17 December, Michael Sheets wrote:
That's a repository rule, you have to include it in the main grammar at some point. Look above and you'll see the php repository item included at some point.
So it was. I hadn't spotted that.
In response to the later email, the order of repository items doesn't matter. But the order they are included in the syntax does matter.
Once I'd referenced my rule before the PHP rule it worked great. Thanks!
If you're modifying the HTML language bundle, i'd advise you to make a copy and modify that. That way you'll still be able to get the latest updates to your default HTML language syntax. If you modify it, textmate will default to your version instead.
—tAylott subtleGradient.com
On Dec 17, 2005, at 9:41 PM, Graham Ashton wrote:
On Saturday 17 December, Michael Sheets wrote:
That's a repository rule, you have to include it in the main grammar at some point. Look above and you'll see the php repository item included at some point.
So it was. I hadn't spotted that.
In response to the later email, the order of repository items doesn't matter. But the order they are included in the syntax does matter.
Once I'd referenced my rule before the PHP rule it worked great. Thanks!
-- Graham
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate