Sublime Forum

Custom Coloration within values of PHP-Arrays

#1

Hi,

it would be great, if anybody could help me:
I write a lot of php-arrays in which I use a custom syntax, delimited with “{{” and “}}”.
Here is an example:

array  (
    "text" => 
    "Ubi ea {{dies||dies (im fem!)||festgesetzter Tag}} venit, Carnutes Gutuatro et Conconnetodumno");

At the moment the whole text has the same (brown) colour. In cases of long texts it’s really difficult and inconvenient to distinguish text from parentheses.
How can I choose another colour for the area between the brackets?

(I am using the “Pastels on Dark”-Theme.)

Thanks a lot in advance!

0 Likes

#2

The double-braces are also embedded in a string, so I think it will be very tricky to re-write the PHP syntax to target these.

I think you might be better served by investigating the **BracketHighlighter **package, although I am unable to confirm whether this will work for braces within strings :question: Edited: The package readme says YES!

0 Likes

#3

You can create your own syntax definition using regexps as shown here. Then you just need to edit the existing PHP definition and add some “include”: “your.new.syntax.scope” (or as xml includethe.new.syntax.scope).

pr0 tip would be to copy the PHP-definition (into your User dir), rename it (also change the “name” key in the file itself) and do the stuff above with that copy. This way you can choose between the normal and your modified syntax.

0 Likes

#4

The BracketHighlighter package indeed provides some help, but I will also give the second advise a try.
Thanks a lot for your help!

0 Likes