I have been utilizing the following code snippet to highlight text segments in Codemirror, a renowned code editor and syntax highlighter that can be downloaded from this link.
Despite referring to the documentation, I am still unable to grasp how this functionality is meant to be properly implemented.
for (var i = 0; i < array.length; i++)
{
var range = array[i].split("-");
editor.getDoc().markText({
line: parseInt(range[0].split(":")[0]) - 1,
ch: parseInt(range[0].split(":")[1])
}, {
line: parseInt(range[1].split(":")[0]) - 1,
ch: parseInt(range[1].split(":")[1])
}, {
css: "color : white; background-color: red; border: 1px;"
});
}
The desired output may look similar to the image found at this URL, but it's purely for illustrative purposes.