DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Modify TextMate's XML Bundle To Use The HTML And JavaScript Bundle In Google Gadgets

04.17.2009
| 4553 views |
  • submit to reddit
        ATTENTION: This is a quick-and-dirty hack. It is not well-tested and unexpected complications can occur when using this hack.

To make use of all of TextMate's hilarious HTML and JavaScript functionality when editing Google Gadgets we need to modify TextMate's XML Bundle.

1. Open TextMate
2. In the menubar go to "Bundles" > "Bundle Editor" > "Edit Languages..."
3. Select "XML" > "XML" in the left drawer
4. Click on the button with two plus signs in the lower left corner of the window
5. Call the new Language definition "XML (Google Gadget)" or something similar
6. In the large text area search for the following code:

{	name = 'string.unquoted.cdata.xml';
	begin = '<!\[CDATA\[';
	end = ']]>';
	beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.xml'; }; };
	endCaptures = { 0 = { name = 'punctuation.definition.string.end.xml'; }; };
},

7. Replace these lines with the following code:

{	name = 'text.html.basic.embedded.xml';
	begin = '<!\[CDATA\[';
	end = ']]>';
	beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.xml'; }; };
	endCaptures = { 0 = { name = 'punctuation.definition.string.end.xml'; }; };
	patterns = ( { include = 'text.html.basic'; } );
},

8. Apply this new Language definition "XML (Google Gadget)" to every XMl document you like. Everything inside the CDATA section will now be treated as HTML.