Sublime Forum

tmLanguage syntax highlighting help please

#1

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)…

				<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.

0 Likes

#2

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:

0 Likes

#3

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 :question:

0 Likes

#4

I can’t tell what’s wrong from that snippet, please paste all the relevant parts or the whole file.

0 Likes