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? ¶meter=`value` ¶meter2=`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 ¶m... (missing ?) or [[Snippet? ¶m='foo' (normal quotation mark)) but this won't work either.
Can you tell me what I did wrong? :)
Regards
Max Lohrmann
On 20. Oct 2006, at 16:14, Max wrote:
There are some Snippet-calls which take parameters: [[Snippet? ¶meter=`value` ¶meter2=`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.
It should be doable, so would need to see the grammar you tried to troubleshoot.
Also when I write a MODx Tag into a html-string (e.g. <a href="[(base_url)]">...) TM will ignore it.
Yes, that’s because of how strings are matched with begin/end. If you edit the existing HTML grammar, add an include for your tags to the embedded-code array in the repository.
If you are making this as a derived grammar (i.e. one that includes the HTML grammar) you are current out of luck (but this will be addressed in the future, it’s a quite frequent problem).
Last I tried to highlight invalid snippet calls (e.g. [[Snippet ¶m... (missing ?) or [[Snippet? ¶m='foo' (normal quotation mark)) but this won't work either.
Again, w/o seeing how you did this, it is difficult to say.
Hi,
thanks for your answer. I pasted my HTML-Language Grammar file here: http://pastie.caboo.se/private/whjiphdom3523otlp0 The code I added is around line 200.
On 21. Oct 2006, at 15:07, Max wrote:
thanks for your answer. I pasted my HTML-Language Grammar file here: http://pastie.caboo.se/private/whjiphdom3523otlp0 The code I added is around line 200.
You should add an include for #modx around line 180-185. That is the rule for the various embedded code stuff, and is included in the root language, strings, tags, etc.
So at least that should make it work inside strings.