GeSHi / geshi-1.0

Original version of Generic Syntax Highlighter for PHP
http://qbnz.com/highlighter/
GNU General Public License v2.0
168 stars 101 forks source link

Support Json format #110

Open ngtrian opened 6 years ago

ngtrian commented 6 years ago

working with xml, yaml, please add json support

cweiske commented 6 years ago

What's your code that is not working?

ngtrian commented 6 years ago

This is my code

{
  "short_name": "Maps",
  "name": "Google Maps",
  "icons": [
    {
      "src": "/images/icons-192.png",
      "type": "image/png",
      "sizes": "192x192"
    },
    {
      "src": "/images/icons-512.png",
      "type": "image/png",
      "sizes": "512x512"
    }
  ],
  "start_url": "/maps/?source=pwa",
  "background_color": "#3367D6",
  "display": "standalone",
  "scope": "/maps/",
  "theme_color": "#3367D6"
}
cweiske commented 6 years ago

I mean your PHP code.

ngtrian commented 6 years ago

Json also not list support on homepage GeSHi

cweiske commented 6 years ago

JSON is a subset of javascript, so JSON is supported. Either show the actual PHP code instructing geshi to render JSON that does not work, or stop.

ngtrian commented 6 years ago

No, if set syntax javascript for json, result in same color. I'm trying in http://qbnz.com.

image

Why quickly closed this issue? Instead of discussing further!

ngtrian commented 6 years ago

It should highlight as: image

cweiske commented 6 years ago

So your problem is that keys and values in a JSON document are highlighted with the same color?

ngtrian commented 6 years ago

So your problem is that keys and values in a JSON document are highlighted with the same color?

yes

BenBE commented 6 years ago

With enough hackery using COMMENT_REGEXP you could match the string preceeding the colon and matching the string except for the colon (which should be covered by a lookahead only, not as the actual match).