I'm enjoying learning how to tweak the language bundles, and there's a lot of good information in the help files and the wiki. There's one small thing so far that I haven't found a good way to do. I'm playing with adding support for heredoc-style embedded HTML in PHP document and have added this to the PHP language syntax definition (version 2.0):
{ name = 'meta.scope.heredoc'; begin = '<<<HTML'; end = '^HTML;'; patterns = ( { include = 'text.html.basic'; } ); }
(Hopefully I haven't made too many embarassing mistakes in those four lines. It seems to work, anyway.)
What I'd like to do is also specially color the heredoc tags, just to make the beginning and end of each block stand out. Is there a "right way" to do that?
A second, minor point about documentation: the wiki says "With regard to syntaxes...there is a help page on how to define these." But the term "syntaxes" isn't actually used in the TextMate help. That didn't stop me from finding the help pages, but this seems like something that would be good to clean up in the wiki for consistency's sake. What's the canonical name for these language syntax definitions?
thanks,
pb
-- paul bissex 69.55.225.29 01061-0847 72°39'71"W 42°19'42"N
On 09/11/2005, at 22.16, Paul Bissex wrote:
[...] What I'd like to do is also specially color the heredoc tags, just to make the beginning and end of each block stand out. Is there a "right way" to do that?
Use captures. In your case that'd be something like:
{ name = 'meta.scope.heredoc'; begin = '<<<(HTML)'; end = '^(HTML);'; patterns = ( { include = 'text.html.basic'; } ); captures = { 1 = { name = "keyword.other.HTML-token"; }; }; }
Then capture #1 of the begin/end match gets assigned keyword.other.HTML-token as name, and you can style that.
You can also specify beginCaptures and endCaptures to only name captures in the begin or end patterns.
If you include \n in the match (capture), styling the background of it will continue to the right border, so that'd make it possible to get sort of a divider line (like e.g. in Diff files or the release notes).
[...] What's the canonical name for these language syntax definitions?
Initially it was syntaxes, but since then, I've referred to them mostly as language grammars, as I think that's a nicer phrase, and they have approached real grammars (since the initial release).
Keeping Syntax Highlight in the Help books table of contents though, was sort of on purpose, since I figured everybody would know what that was about.
On 11/10/05, Allan Odgaard throw-away-1@macromates.com wrote:
On 09/11/2005, at 22.16, Paul Bissex wrote:
[...] What I'd like to do is also specially color the heredoc tags, just to make the beginning and end of each block stand out. Is there a "right way" to do that?
[snip]
[...] What's the canonical name for these language syntax definitions?
Initially it was syntaxes, but since then, I've referred to them mostly as language grammars, as I think that's a nicer phrase, and they have approached real grammars (since the initial release).
Nicer, I agree. Thanks for the answers!
pb
-- Paul Bissex http://e-scribe.com/news/ Northampton MA USA 01061-0847