[TxMt] MODx Syntax Highlighting

Max lists at wickenrode.com
Fri Oct 20 14:14:55 UTC 2006


Hi,

I've been using TM for quite some time now and it's a great editor.
The last weeks I had to write some code for a site using MODx
(www.modxcms.com)
MODx uses some special tags:

[[Snippet]]
[!Noncaching-Snippet!]
{{Chunk}}
[~link~]
[*attribute*]

I added some code to the HTML-Bundle for recognizing this which works
quite good.

modx = { patterns = (
                {    name = 'meta.tag.inline.modx.snippet';
                    begin = '(\[\[)(\w*)(.*?)';
                    end = '(\]\])';
                    captures =
                    {    1 = { name = 'punctuation.modx.snippet'; };
                        2 = { name = 'entity.name.tag.modx.snippet'; };
                    };
                },
                {    name = 'meta.tag.inline.modx.snippet.nocache';
                    begin = '(\[\!)(\w*)(.*?)';
                    end = '(\!\])';
                    captures =
                    {    1 = { name = 'punctuation.modx.nocachesnippet'; };
                        2 = { name =
'entity.name.tag.modx.snippet.nocache'; };
                    };
                },
                {    name = 'meta.tag.inline.modx.link';
                    begin = '(\[\~)(\w*)';
                    end = '\~\]';
                    captures =
                    {    1 = { name = 'punctuation.modx.link'; };
                        2 = { name =
'entity.name.tag.modx.snippet.nocache'; };
                    };
                },
                {    name = 'meta.tag.inline.modx.setting';
                    begin = '(\[\()(\w*)';
                    end = '(\)\])';
                    captures =
                    {    1 = { name = 'punctuation.modx.setting'; };
                        2 = { name = 'entity.name.tag.modx.setting'; };
                    };
                },
                {    name = 'meta.tag.inline.modx.chunk';
                    begin = '({{)(\w*)';
                    end = '(}})';
                    captures =
                    {    1 = { name = 'punctuation.modx.chunk'; };
                        2 = { name = 'entity.name.tag.modx.chunk'; };
                    };
                },
                {    name = 'meta.tag.inline.modx.attribute';
                    begin = '(\[\*)(\w*)';
                    end = '(\*\])';
                    captures =
                    {    1 = { name = 'punctuation.modx.attribute'; };
                        2 = { name = 'entity.name.tag.modx.attribute'; };
                    };
                },
                {    name = 'variable.parameter.modx';
                    match = '(&\w+)=';
                },
                {    name = 'string.quoted.modx';
                    begin = '`';
                    end = '`';
                },
                {    name = 'invalid.illegal.modx.bad-snippetcall';
                    match = '(\[[\[\!])(\w+)(\s+)(.+?)([\!\]]\])';
                },
            );
        };

Now my problem is:
There are some Snippet-calls which take parameters:
[[Snippet? &parameter=`value` &parameter2=`value2`]]
I tried to define the parameters as variable.parameter.modx and the
values as string.quoted.modx but TM doesn't seem to recognize this.
Also when I write a MODx Tag into a html-string (e.g. <a
href="[(base_url)]">...) TM will ignore it.
Last I tried to highlight invalid snippet calls (e.g. [[Snippet
&param... (missing ?) or [[Snippet? &param='foo' (normal quotation
mark)) but this won't work either.

Can you tell me what I did wrong? :)

Regards

Max Lohrmann




More information about the textmate mailing list