| 191 | } |
| 192 | |
| 193 | function 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. |
| 208 | function runMode(cm, text, mode, context, f, lineClasses, forceToEnd) { |