[TxMt] BBCode syntax highlighting

Allan Odgaard allan at macromates.com
Fri Aug 5 23:36:24 UTC 2005

On 06/08/2005, at 1.20, Douglas Livingstone wrote:

> I'd like to add support for highlighting the syntax of BBCode, but I'm
> not really sure where to start. The main feature I'm looking for at
> the moment is to turn on PHP syntax highlighting when you are inside a
> [php] code [/php] section.
> Where should I start looking for files to edit?

View -> Language -> Edit Languages…

Start by selecting New Bundle from the + menu. Name it BBCode and  
then select New Language. This gives you a new language grammar which  
you can edit. Change scopeName to "text.bbcode", insert potential  
file types in the fileTypes array and add your patterns to the  
patterns array.

To match [php]...[/php] you'd add this rule to it (you probably want  
to remove the two default rules in this array):

     {   name = "source.php.embedded.bbcode";
         begin = "\\[php\\]"; end = "\\[/php\\]";
         patterns = (
             { include = "source.php"; }

For more information about the format see Help / Syntax Highlight.  
You may also want to read some of the articles at my blog for  
supplementary information, e.g. [1] and [2].

And also take a look at some of the other language files.

Hope that helps...

[1] http://macromates.com/blog/archives/2005/07/06/introduction-to- 
[2] http://macromates.com/blog/archives/2005/06/23/language-grammars/

More information about the textmate mailing list