Hello! I have a problem with syntax highlighting in Sublime Text 3 ...
I installed the Bracket Highlighter module to highlight the HTML syntax.
And he works strangely enough ...

It only highlights the tag name itself without angle brackets ...
I would like it to work this way:

Thank.

{ "bracket_styles": { // This particular style is used to highlight // unmatched bracket pairs. It is a special // style. "unmatched": { "icon": "question", "color": "brackethighlighter.unmatched", "style": "highlight" }, // User defined region styles "curly": { "icon": "curly_bracket", "color": "brackethighlighter.curly", "style": "highlight" }, "round": { "icon": "round_bracket", "color": "brackethighlighter.round", "style": "outline" }, "square": { "icon": "square_bracket", "color": "brackethighlighter.square", "style": "outline" }, "angle": { "icon": "angle_bracket", "color": "brackethighlighter.angle", "style": "outline" }, "tag": { "icon": "tag", "color": "brackethighlighter.tag", "style": "outline" }, "single_quote": { "icon": "single_quote", "color": "brackethighlighter.quote", "style": "outline" }, "double_quote": { "icon": "double_quote", "color": "brackethighlighter.quote", "style": "outline" }, "regex": { "icon": "regex", "color": "brackethighlighter.quote", "style": "outline" } } } 
  • one
    The githaba already has a ticket based on your question. - D-side
  • one
    The main problem with this behavior, as I understand it, is that the tag can consist not only of the name and parentheses, but also the attributes and their values. For individual components, it has separate matchrs, and highlighting only the tag name is hammered into the code with nails . It seems that Python is required, configs will not do. - D-side
  • Is it possible that this is a module bug? - php_array
  • I think this is a module feature . The comments on the link clearly states that this is intended behavior. You can start by modifying the package by removing these lines . But this is a guessing game, I have no idea what happens in this case%) - D-side
  • Then a bit of a strange feature))) Since the picture shows one work))) But in fact it is different, and nowhere is it indicated how to make it work like in the picture) I put the module in order for it to work like in the picture xD - php_array

3 answers 3

Having rummaged in implementation, I found a hole in a configuration file .
It is not documented and may disappear at any time, and also makes it impossible to set up another thing , but it is working at the moment.

Find the tag configuration file:

  • Preferences (in the menu bar)
  • Package Settings
  • Brackethighlighter
  • Tag Settings - User

... and make the following settings:

 { "tag_style": {"html": null} } 

Everything. Save and try.

But if you wonder how it happened ...


What? ..

The fact is that the author of the package initially highlighted the entire tag. And the picture in the repository since those times. But it annoyed him and he narrowed the backlight only to the name of the tag.

And as a conscious programmer, he made it a separate function , carefully integrating it into the right place. The left - right range is transferred to it, in which the element to be highlighted is placed, the function narrows it down to exactly which piece should be highlighted and returned.

 def highlighting(view, name, style, left, right): """Highlight only the tag name.""" tag_settings = sublime.load_settings("bh_tag.sublime-settings") match_style = tag_settings.get("tag_style", {}).get(last_mode, None) if match_style is not None and style == match_style: tag_name = tag_settings.get('tag_name', {}).get(last_mode, '[\w\:\.\-]+') if left is not None: region = view.find(tag_name, left.begin) left = left.move(region.begin(), region.end()) if right is not None: region = view.find(tag_name, right.begin) right = right.move(region.begin(), region.end()) return left, right 

I have commented out the entire contents of this function except the last line, so that the range is returned intact. And it worked. But then I noticed that the restriction is already hidden in if and wondered if it was possible to cut it off.

As it turned out, you can. You can force match_style be None , since its value is taken directly from the configuration. The procedure described above replaces it.

Having rummaged, you can collect the version of this packet without narrowing, having commented out in this function everything, except return left, right . Then the hack in the configuration file is not required. Installing modified packages is not too complicated .

You can even fork the package, make a change in it, and install it directly from the github via the Package Control using the "Add Repository". MIT license does not prohibit it.

  • Maybe pull-request will do? - Sasha Chernykh
  • @ SashaBlack not take it. (a) I don't know Python at all. (b) I do not know if the described changes are blasting anything else. - D-side
  • Thank you very much. Now it would be cool to put it all in the "outline". Can this be done through the styles of the color theme itself? - php_array
  • @php_array is a regular way to customize the styles of tags when using this hack just breaks. Therefore, if you are not satisfied with the default style, you will have to make a modified package, removing the above lines. - D-side

Not sure, but the author of this module seems to have planned this behavior ...
Here are his words ...
But I cannot be sure of the correctness of my translation, since I do not know English well ...
Please explain if I understand correctly?

Make sure you’re following the repo. Eventually, all of my repos will follow a similar pattern. I appreciate the fact that it was vs actual, but it was helpful for me to get info such as how it can be resolved.

"I don't understand how I can highlight angle brackets in tags."

To answer your question now. The main picture of the tag has been highlighted. That was from a much earlier version of bracket highlighter. It has been highlighted (attributes and all). It is a little bit less annoying. It is a bit more difficult to compare with the attributes.

Unfortunately, it is not configurable. Ideally, it shouldn’t be the current behavior.
  • one
    That is, I was right. The picture is just from the old version. Stroking the entire tag was a bit annoying, and it limited the highlighting to just the tag name. - D-side
  • Damn, well, he certainly gives ... And to improve the regulator in any way ... Though take the python and API ST3 ... and write it yourself)))) - php_array
  • Since the regular tag name is also responsible for matching the tags, its replacement will break everything to hell :) - D-side
  • Well, you need to write from scratch)))) - php_array
  • Not really. I just checked my guess in the comments and it works. Well ... on a pair of artificial tests. I'll check on something heavier now. - D-side

According to the plugin's documentation , in bh_core.sublime-settings you can change the display mode for the characters you need (brackets, slashes, dots).

In your case, I think this is "angle", the "style" parameter should be "highlight". It looks something like this, try playing with the parameters

 "angle": { "icon": "angle_bracket", "color": "brackethighlighter.angle", "style": "highlight" } 
  • one
    The fact is that I have been conjuring with this module for 2 days))) <br> <br> - php_array
  • And I tried to mess with styles and so on, and it doesn't help ( - php_array
  • @php_array lay out the contents of your settings file in the question where you play with styles, we will look. will compare with the docks - while1pass
  • one
    @ while1pass I am familiar with the documentation, I personally use this package and have already clearly indicated why this answer has nothing to do with the question. - D-side
  • one
    As soon as you show where exactly your answer contains a working solution, I will immediately remove my minus :) - D-side