Home Download Buy Blog Forum Support

tmLanguage syntax highlighting help please

tmLanguage syntax highlighting help please

Postby hArpanet on Fri May 17, 2013 1:12 pm

Hi,

I'm trying to create a new syntax definition for DokuWiki (.txt) files as the existing plugin doesn't work and I thought I'd have a go at it myself to learn.

As with many languages, there are recursive elements to be highlighted.

Eg. //**hello world**//

In the above, // ... // denotes italics, and ** ... ** denotes bold begin/end boundaries.

In ST3, I would like the above example to appear in italics AND bold, but I can only get it to do one or the other.

In my .tmLanguage file I have the following definition (yes, I'm coding directly in xml not JSON)...

Code: Select all
           
            <dict>
               <key>comment</key>
               <string>//italic text//</string>

               <key>begin</key>
               <string>(//)</string>

               <key>beginCaptures</key>
               <dict>
                  <key>1</key>
                  <dict>
                     <key>name</key>
                     <string>container.inline.dokuwiki_st3</string>
                  </dict>
                     </dict>

               <key>end</key>
               <string>(.*)(//)</string>
                     
                     <key>endCaptures</key>
                     <dict>
                  <key>1</key>
                  <dict>
                     <key>name</key>
                     <string>italic.dokuwiki_st3</string>
                  </dict>
                  <key>2</key>
                  <dict>
                     <key>name</key>
                     <string>container.inline.dokuwiki_st3</string>
                  </dict>
               </dict>

               <key>patterns</key>
               <array>
                  <dict>
                     <key>include</key>
                     <string>#inline</string>
                  </dict>
               </array>
            </dict>


I also have another 'identical' definition to match the bold settings.

I'm a newbie in regular expressions, but any help in allowing both bold AND italics to be applied would be much appreciated. I had assumed that the 'include #inline' would have caused this recursion automatically, but apparently not.

Thanks.
hArpanet
 
Posts: 3
Joined: Fri May 17, 2013 12:58 pm

Re: tmLanguage syntax highlighting help please

Postby hArpanet on Fri May 17, 2013 3:23 pm

Hmm, I guess my request is very similar to fcgrx in How to highlight a nested scope? so it doesn't look good for a reply anytime soon :cry:
hArpanet
 
Posts: 3
Joined: Fri May 17, 2013 12:58 pm

Re: tmLanguage syntax highlighting help please

Postby agibsonsw on Sat May 18, 2013 6:22 pm

I'm afraid the only advice I can offer is to find nested-syntax highlighting that works in another (hopefully similar) language, and borrow from and study its language file.

Maybe someone else can assist you, or point you to some reference material :?:
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: tmLanguage syntax highlighting help please

Postby FichteFoll on Thu May 30, 2013 11:39 pm

I can't tell what's wrong from that snippet, please paste all the relevant parts or the whole file.
FichteFoll
 
Posts: 386
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 4 guests