Hi,
I have the unfortunate job of writing a bunch of Windows Script Components (psuedo COM objects written in scripting languages). In my case, it is just some VBScript wrapped in some XML.
I hacked up a really lame VBScript bundle by basically ripping off the ASP bundle. What I would like to do is have the VBScript portion of the XML file be treated by TextMate as VBScript.
The script portion of the document looks like this...
<script language="VBScript"> <![CDATA[
' VBScript here.
]]> </script>
Can I get some help from the bundle gurus please :)
Thanks,
LD.
On 3/7/2006, at 4:52, Luke Daley wrote:
The script portion of the document looks like this...
<script language="VBScript"> <![CDATA[ ' VBScript here. ]]> </script>
Can I get some help from the bundle gurus please :)
If you have given your vbscript grammar a scope name of source.vbscript, you would need a rule similar to this in the HTML grammar:
{ name = 'source.embedded.vbscript'; begin = '<script language="VBScript">'; end = '</script>'; patterns = ( { include = 'source.vbscript'; }, ); },
Then when it sees the <script language="VBScript"> tag, it will include your vbscript grammar and not exit this mode before it sees </ script>.
On 03/07/2006, at 6:07 PM, Allan Odgaard wrote:
If you have given your vbscript grammar a scope name of source.vbscript, you would need a rule similar to this in the HTML grammar:
{ name = 'source.embedded.vbscript'; begin = '<script language="VBScript">'; end = '</script>'; patterns = ( { include = 'source.vbscript'; }, ); },
Then when it sees the <script language="VBScript"> tag, it will include your vbscript grammar and not exit this mode before it sees </script>.
Thanks for the help Allan. I can't seem to get it to work though, does something in the begin or end labels need to be escaped?
LD.
On 3/7/2006, at 10:31, Luke Daley wrote:
Thanks for the help Allan. I can't seem to get it to work though, does something in the begin or end labels need to be escaped?
Shouldn’t be necessary. Try post more context.
If you’re adding to the default HTML grammar, be sure to place the rule above the JS <script> rule.
On 03/07/2006, at 6:38 PM, Allan Odgaard wrote:
Shouldn’t be necessary. Try post more context.
If you’re adding to the default HTML grammar, be sure to place the rule above the JS <script> rule.
Shouldn't I be adding it to the XML grammar? Apologies for not be clearer about that.
I am working with .wsc files which are XML declarations of simple COM objects which TextMate already recognises as XML.
.....
Actually, just worked out what is wrong. I moved it from the bottom of the list of declerations to the top and it works now :) I wasn't aware that order played a part (I know, RTFM).
I suspect now it has destroyed other declarations though.
I am working with this inside an XML document...
---
<script language="VBScript"> <![CDATA[
' VBScript here.
]]> </script>
---
What would be ideal is to treat everything inside '<script language="VBScript">\n<![CDATA[' and ']]>\n</script>' as 'source.vbscript'
Is there a way to match everything inside these tags excluding the tags themselves?
I do promise to package this up as a seperate WindowsScriptingComponents.tmbundle once I have the know how (not that I expect many to use it, but it can't hurt).
Thanks again,
LD.
On 3/7/2006, at 11:07, Luke Daley wrote:
If you’re adding to the default HTML grammar, be sure to place the rule above the JS <script> rule.
Shouldn't I be adding it to the XML grammar? Apologies for not be clearer about that.
I am working with .wsc files which are XML declarations of simple COM objects which TextMate already recognises as XML.
Then XML sounds right.
.....
Actually, just worked out what is wrong. I moved it from the bottom of the list of declerations to the top and it works now :) I wasn't aware that order played a part (I know, RTFM).
I suspect now it has destroyed other declarations though.
Shouldn’t have -- your rule wasn’t applied because a more general tag matching rule ate the tag. By moving your rule up, it gets the script tag, and still leaves the rest to the general rule.
What would be ideal is to treat everything inside '<script language="VBScript">\n<![CDATA[' and ']]>\n</script>' as 'source.vbscript'
Is there a way to match everything inside these tags excluding the tags themselves?
That’s what the begin/end stuff does. The begin matches the start (though it can’t match newlines, thus we do just the script tag) and end matches the end. The patterns array then setup rules to use inside this construct (where we could just include another grammar).
There are a dozen examples of this in the default grammars, e.g. HTML includes CSS, JavaScript, PHP, and Ruby inside various special constructs.