MCPcopy Create free account
hub / github.com/breck7/scroll / extractLineClasses

Function extractLineClasses

external/.scrollLibs.js:2662–2679  ·  view source on GitHub ↗
(type, output)

Source from the content-addressed store, hash-verified

2660 }
2661
2662 function extractLineClasses(type, output) {
2663 if (type) {
2664 for (;;) {
2665 var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/)
2666 if (!lineClass) {
2667 break
2668 }
2669 type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length)
2670 var prop = lineClass[1] ? "bgClass" : "textClass"
2671 if (output[prop] == null) {
2672 output[prop] = lineClass[2]
2673 } else if (!new RegExp("(?:^|s)" + lineClass[2] + "(?:$|s)").test(output[prop])) {
2674 output[prop] += " " + lineClass[2]
2675 }
2676 }
2677 }
2678 return type
2679 }
2680
2681 // Run the given mode's parser over a line, calling f for each token.
2682 function runMode(cm, text, mode, context, f, lineClasses, forceToEnd) {

Callers 1

runModeFunction · 0.85

Calls 1

sliceMethod · 0.80

Tested by

no test coverage detected