-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Monokai themes don't highlight JSON right #669
Comments
Thanks for reporting it. It is, in fact, a known glitch and we left it as is for now until the upcoming overhaul of class names and styles in #348. |
Perfect. Looking forward to the overhaul then! |
I also found some other highlighting issues when using json within a function call - this happens with any style, not just Monokai Works correctly
Works incorrectly:
|
@danelkhen This isn't a bug considering JSON doesn't have functions. Use javascript when you are using features outside of the JSON definition. Also the first example looks like it was highlighted in javascript since |
@sourrust |
JSON is not JavaScript. Look at the example you provided, it is a JavaScript object not JSON. JSON looks like this: {
"title": "Line - 2 Columns (x and y)",
"data": [ {
"columns": ["x", "y"],
"rows": [
[10, 20],
[20, 50],
[30, 10],
[40, 90],
[50, 120],
],
}],
} Note the double quotes and no variable declaration or function calls. If you use the examples you provided in JSON you will have an error even with Github's highlighter. See for yourself: var x = {
title: "Line - 2 Columns (x and y)",
data: [ {
columns: ["x", "y"],
rows: [
[10, 20],
[20, 50],
[30, 10],
[40, 90],
[50, 120],
],
}],
}; Use JavaScript for those cases. |
I think that the term JSON in my title has thrown you off. Cuz I'm not sure what you mean by "use javascript". I am using highlight.js in javascript mode, and it colors it wrong. That's all I'm trying to say. Let me ask it another way - is there a way in highlight.js to make my valid code be to be highlighted correctly? |
Right, I was stuck in the that mindset because this issue is about JSON. So I'm guessing you are using autodetection and the language highlight.js is choosing is JSON? The way you specify a language is: <pre><code class="javascript">...</code></pre> That autodetection error might have been fixed in a later versions than what you are using because 8.4 and the master branch doesn't detect the snippet as JSON. If this isn't your problem, can you make a separate issue? With this new information, your possible bug has nothing to do with the original issue. |
I think I tried it, but I'll double check and get back to you. Thanks! |
You're right, it has detected it as css instead of js. Seems to render fine when explicitly setting class='javascript' |
The Monokai themes do not highlight the JSON format right. The second-level braces and quotes for keys do not appear white as they should. I attach two screenshots taken from the official demo:
The text was updated successfully, but these errors were encountered: