10

Background

I am working with a language called Webclerk, which uses custom tags to query a 4D database. It works similarly to PHP. Instead of a .php file which is processed into HTML, this uses a '.wc' file which is processed into HTML.

Instead of something like: <?php echo $variable; ?>, it would look like _jit_ echo $variable; jj

<?php = _jit_, ?> = jj.

In Sublime Text, when PHP is selected as the Syntax, PHP is highlighted a different block color, on top of the HTML highlighting. I'd like to do the same thing for these special tags.

I really don't care about highlighting text inside the brackets. I would be completely satisfied with just having a highlight/background color starting and stopping with the tags.

What I've Done

I have installed Package Manager, and Package Resource Viewer, then extracted the PHP and the HTML packages to examine them. I've been going through tutorials as well. I'm running into a problem with the two different types of syntax highlighting (.tmLanguage vs .sublime-syntax). There is a lot of info on the first way, and very little on the second. I feel like just starting and stopping highlighting based on two tags can't be that difficult.


When I opened the HTML package, I get:

Comments.tmPreferences
HTML.sublime-syntax
Miscellaneous.tmPreferences
Symbol List - ID.tmPreferences
encode_html_entities.py
html.sublime-snippet
html_completions.py

Almost none of these are mentioned in tutorials. I tried just changing the names of HTML to Webclerk, and I did manage to get a new Syntax in the list. But when I edited tags, nothing changed in what was highlighted.

Question

I'm wondering if I can get some pointers on where to start, on what these files mean, and potentially any examples where people have extended HTML before.

Community
  • 1
  • 1
Kelderic
  • 6,502
  • 8
  • 46
  • 85

1 Answers1

1

basically you're trying to define a custom scope with a start & end regexp selectors that is documented here: http://sublimetext.info/docs/en/extensibility/syntaxdefs.html#begin-end-rules

I have also ran into this intresting discussion on the sublime text board from somebody trying to do exactcly what you're trying to do http://www.sublimetext.com/forum/viewtopic.php?f=6&t=6207 There is some helpful information and tips in it.

I would start in the HTML.sublime-package package inside HTML.tmLanauage package on line 598 (in my setup) there is a definition for php start & end tags, it looks like a regex that recognizes the tags and highlights them

BTW .sublime-package are just zip files, you can rename them and extract. then put the extracted folder inside %APPDATA%\Sublime Text 3\Installed Packages to run it

dcohenb
  • 2,099
  • 1
  • 17
  • 34
  • I've been looking at those links. Still haven't gotten it working fully, but I'm going to award you the bounty so that it doesn't disappear. – Kelderic Sep 22 '15 at 15:12
  • 3
    There are several issues with this answer: first, the OP is using a [dev build](https://sublimetext.com/3dev) of ST3, meaning all the default `.tmLanguage` files have been replaced with the new YAML-based `.sublime-syntax` files. Second, all the business about zip files and `HTML.sublime-package` are completely unnecessary - OP is already using PackageResourceViewer, which does all of that seamlessly. Finally, you don't put extracted packages in `Installed Packages`, they go in `Packages`, otherwise they won't override the zipped version. – MattDMo Jan 24 '16 at 04:50