#JSON key-value string highlighting

5 messages · Page 1 of 1 (latest)

young pagoda
#

I am currently creating a document where I want to include code blocks that contain JSON, a minimal example would be the following:

{
  "foo": "bar"
}

In the example above you can observe that the key and value strings are displayed in different colors here on Discord. In the document rendered by Typst, however, the same color is used for both key and value strings, see the attached screenshot.

I know that it is possible to change the formatting for raw elements and I also found some files created for Sublime Text (which is the input format accepted by the raw element's syntaxes parameter) that are supposed to change the syntax highlighting – but I couldn't get it to work yet.

Does someone maybe have a simple example for how this could be done? And would it maybe make sense to change the default JSON highlighting in general to have a distinction between keys and values? Thanks!

stiff lance
#

The syntaxes parameter isn't necessarily intended for changing syntax highlighting but rather adding custom languages. I suppose it could change some internal highlighting if that .sublime-syntax file classifies keys and values differently somehow.

You can try to look for .tmTheme files though and look at the theme parameter of raw since that is intended to change the existing highlighting colors. I don't know if that format is general enough to be able to differentiate what you want though since it probably sees both values as "String" but it's worth a try.

If all else fails, I guess a scoped show rule will work.

young pagoda
#

Ahh, thank you, using theme instead of syntaxes (with an appropriate input) already helped a lot :)

eternal bobcat
#

Why did the answers pop up after i wrote this 😭