Replies: 1 comment
-
You could use something like this: "use strict";
var oop = require("../lib/oop");
var JsonHighlightRules = require("./json_highlight_rules").JsonHighlightRules;
var words = Object.create(null)
words["count"] = "keyword"
words["id"] = "keyword"
words["farm"] = "keyword"
var JsonHighlightRules2 = function() {
JsonHighlightRules.call(this)
// regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used
var i = this.$rules.start.findIndex( x=> x.token == "variable")
this.$rules.start.splice(i, 1, {
token : function(value) {
var endI = value.lastIndexOf('"')
var word = value.slice(1, endI)
return [
{value: '"', type: "string"},
{value: word, type: words[word] || "variable"},
{value: value.slice(endI), type: "string"}
]
},
regex : '"(?:(?:\\\\.)|(?:[^"\\\\]))*?"\\s*(?=:)'
})
};
oop.inherits(JsonHighlightRules2, JsonHighlightRules);
exports.HighlightRules = JsonHighlightRules2; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm looking at how to highlight specific words inside JSON values, this works as a custom mode:
https://stackoverflow.com/a/43757653
But how do I apply it to the JSON mode? It seems it needs to be patched into
ace/mode/text_highlight_rules
.But I can't find how to do that.
Beta Was this translation helpful? Give feedback.
All reactions