Home Download Buy Blog Forum Support

Syntax Definition referencing other syntax definitions

Syntax Definition referencing other syntax definitions

Postby cfrolik on Wed Jul 30, 2014 3:23 pm

I have my own custom file format that looks something like this... (oversimplified)

@module{module-name}

@section{section1}
<text goes here>
@section{section2}
<text goes here>
@code
<code goes here>
@end

I've successfully made a .tmLanguage file for this, since it is very simple.
However, I want the <text goes here> parts to highlight as Markdown, and I want the <code goes here> parts to highlight as JavaScript.
But, I don't want to copy/paste the .tmLanguage content for Markdown and JavaScript into my .tmLanguage file; instead, I just want to "include" them within a begin/end pattern.

Is this possible?
cfrolik
 
Posts: 2
Joined: Wed Oct 24, 2012 2:00 pm

Re: Syntax Definition referencing other syntax definitions

Postby sapphirehamster on Thu Jul 31, 2014 9:46 pm

Use "include" to include other syntaxes. For example with javascript in the patterns list:

Code: Select all
         <key>patterns</key>
         <array>
            <dict>
               <key>include</key>
               <string>source.js</string>
            </dict>
         </array>


See https://sublime-text-unofficial-documen ... xdefs.html
and http://manual.macromates.com/en/language_grammars
for more information on using "include" and grammars in general.

Also look at all the tmLanguage files that ship with Sublime. Many of them use includes to embed other languages.
sapphirehamster
 
Posts: 90
Joined: Sun Jul 01, 2012 11:19 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 7 guests