MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / extractLineClasses

Function extractLineClasses

lib/web/CodeMirror/src/line/highlight.js:193–205  ·  view source on GitHub ↗
(type, output)

Source from the content-addressed store, hash-verified

191}
192
193function extractLineClasses(type, output) {
194 if (type) for (;;) {
195 let lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/)
196 if (!lineClass) break
197 type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length)
198 let prop = lineClass[1] ? "bgClass" : "textClass"
199 if (output[prop] == null)
200 output[prop] = lineClass[2]
201 else if (!(new RegExp("(?:^|\\s)" + lineClass[2] + "(?:$|\\s)")).test(output[prop]))
202 output[prop] += " " + lineClass[2]
203 }
204 return type
205}
206
207// Run the given mode's parser over a line, calling f for each token.
208function runMode(cm, text, mode, context, f, lineClasses, forceToEnd) {

Callers 1

runModeFunction · 0.70

Calls 2

matchMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected