# Highlighters

**URL:** <https://discuss.kakoune.com/t/highlighters/543>\
**Category:** Manual++\
**Created:** [May 8, 2019, 2:18am UTC](https://discuss.kakoune.com/t/highlighters/543 "2019-05-08T02:18:39Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![EpocSquadron](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/epocsquadron/32/78_2.png) [@EpocSquadron](https://discuss.kakoune.com/u/EpocSquadron)\
**Post date:** [October 17, 2020, 1:14am UTC](https://discuss.kakoune.com/t/highlighters/543/2 "2020-10-17T01:14:01Z")

</div>

One thing that isn’t clear here is how to nest regions. Adding another group to a group that has regions declared doesn’t seem to be allowed, but that isn’t obvious from this man page.

By staring at a bunch of the built in language highlighters, I was able to determine that at least one way is to create a group, add regexes to it, then create a new, unrelated group and some regions which then ref the first group. For example, in many templating languages (twig, mustache, etc), there are two kinds of tag regions, one for logical operations, the other for outputting variables. If you want to highlight a strings region within either of those regions, you need to define the two tag types as refs to the language grammar that includes string regions. This seems to be the resolution to the problem I stated here:

> [@Having trouble highlighting strings inside a nested region](https://discuss.kakoune.com/t/having-trouble-highlighting-strings-inside-a-nested-region/870):
>
> I’m attempting to create a syntax highlighter for twig templates, based on the highlighter for django templates in kakoune-extra. The highlighter splits itself into three groups, code, scope and expansion. The first calls out to the html highlighter. The other two handle the two types of tags that are available in twig – one for logic and one for output. add-highlighter shared/twig/code default-region ref html add-highlighter shared/twig/scope region '\{%' '%\}' group add-highlighter shared/twi…

I’m sure there’s more tricks to be learned here. Looking at the JavaScript language kak script is bewildering. It uses recursion in a way I don’t have time to reverse engineer.

---

_[View the full topic](https://discuss.kakoune.com/t/highlighters/543)._
