Hi,
last time I asked, this wasn't possible and I did not follow the latest development. So here's my question again:
I have a custom html/php dialect. It contains of regions of code that is either html markup or php code.
<php>...</php>
and
<htm>...</htm>
Inside a php region, you can use <htm> and inside a markup region, you can use <php> which leads to recursive a structure that is very helpful for programming (at least for me) but harder to colorize, fold or autocomplete correctly.
More complex example (outmost default is html markup):
<html> <head> <php> echo convert($title); </php> <style> ..... </style> </head> <php> init(); </php> <body> Result: <php> if($someflag) <htm> <table border="0"> <php> foreach $row ($rows) { <htm><tr><td></htm> echo $row; <htm></td></tr></htm> } </php> </table> </htm> </php> </body> </html>
Can I customize Textmate so its html and php modules identify my regions?
/Andreas Pardeike
On 8 Apr 2009, at 10:42, Andreas Pardeike wrote:
[...] Can I customize Textmate so its html and php modules identify my regions?
Yes, look at the ‘include’ rule key: http://manual.macromates.com/en/language_grammars#rule_keys
On 8 apr 2009, at 21.34, Allan Odgaard wrote:
On 8 Apr 2009, at 10:42, Andreas Pardeike wrote:
Can I customize Textmate so its html and php modules identify my regions?
Yes, look at the ‘include’ rule key: http://manual.macromates.com/en/language_grammars#rule_keys
Great. Much improved since I looked last. My grammar def looks like this:
{ scopeName = 'text.html.basic'; fileTypes = ( ); foldingStartMarker = '<(php|htm)>$'; foldingStopMarker = '^\s*</(php|htm)>'; patterns = ( { contentName = 'source.php'; begin = '`|<php>\s*?\n?|</htm>\s*?\n?'; end = '`|\s*<htm>|^\s*</php>|</php>'; patterns = ( { include = 'source.php'; } ); }, ); }
Question: I don't get syntax coloring for the two scopes though. Is this possible?
/Andreas Pardeike
Update,
Using
{ scopeName = 'text.html.php'; fileTypes = ( ); foldingStartMarker = '<(php|htm)>$'; foldingStopMarker = '^\s*</(php|htm)>'; patterns = ( { contentName = 'source.php.embedded.html'; begin = '`|<php>\s*?\n?|</htm>\s*?\n?'; end = '`|\s*<htm>|^\s*</php>|</php>'; patterns = ( { include = 'source.php'; } ); }, { include = 'text.html.basic'; }, ); }
I get syntax coloring for the html scope, but not for php. /Andreas
On 9 apr 2009, at 08.48, Andreas Pardeike wrote:
On 8 apr 2009, at 21.34, Allan Odgaard wrote:
On 8 Apr 2009, at 10:42, Andreas Pardeike wrote:
Can I customize Textmate so its html and php modules identify my regions?
Yes, look at the ‘include’ rule key: http://manual.macromates.com/en/language_grammars#rule_keys
Great. Much improved since I looked last. My grammar def looks like this:
{ scopeName = 'text.html.basic'; fileTypes = ( ); foldingStartMarker = '<(php|htm)>$'; foldingStopMarker = '^\s*</(php|htm)>'; patterns = ( { contentName = 'source.php'; begin = '`|<php>\s*?\n?|</htm>\s*?\n?'; end = '`|\s*<htm>|^\s*</php>|</php>'; patterns = ( { include = 'source.php'; } ); }, ); }
Question: I don't get syntax coloring for the two scopes though. Is this possible?
On 9 Apr 2009, at 11:10, Andreas Pardeike wrote:
[...] { include = 'text.html.basic'; },
I get syntax coloring for the html scope, but not for php.
Because when you include the HTML grammar, you delegate all further parsing (of tags) to this grammar, i.e. your custom <php> tags are then parsed by the included grammar.
Afraid you’ll have to role your own (full) grammar for this custom language (or edit the HTML grammar to skip parsing <php> tags).