[TxMt] Re: code coloring/language scope question

Allan Odgaard mailinglist at textmate.org
Thu Jul 29 12:45:35 UTC 2010


On 22 Jul 2010, at 01:10, bennett von bennett wrote:

> On Wed, Jul 21, 2010 at 1:44 AM, Allan Odgaard <mailinglist at textmate.org 
> >wrote:
>> On 20 Jul 2010, at 09:47, plastichairdoo wrote:
>>> [...] I know that there's a way to use different code coloring for
>>> different parts of a document [...]
>> [...] Are you writing your own language grammar?
>
> actually no - I'd prefer it if someone has already accomplished this  
> - this
> functionality exists for PHP and CSS and (sometimes) for JS code  
> inside an
> HTML page but I was recently working with Processing.js which gets  
> put into
> <pre> tags and it all gets treated as plain text.
> here is a screenshot.
> since I don't really know how to change this or add new tag colors  
> etc it
> seemed like a good learning opportunity.

For this you need to alter the grammar.

There is one root grammar for your document, e.g. HTML for a HTML file.

This grammar will match tags like <style> and <script> and either  
include another grammar or put special rules only active inside this  
context.

If you want text between <pre>…</pre> to be marked up as Processing.js  
then you need to alter the HTML grammar to match <pre> tags and  
include a processing grammar for these (or define it inline).

For more info see http://manual.macromates.com/en/language_grammars


More information about the textmate mailing list