| 262 | } |
| 263 | |
| 264 | function colorizePlainText(text: string) { |
| 265 | const num = /(?<=^|[^A-Za-z0-9_\-\.])[0-9]+(\.[0-9]+)*(?=$|[^A-Za-z0-9_\-\.])/g; |
| 266 | let m: RegExpExecArray | null; |
| 267 | let lastIndex = 0; |
| 268 | const fragments: string[] = []; |
| 269 | while (m = num.exec(text)) { |
| 270 | fragments.push(text.substring(lastIndex, m.index)); |
| 271 | fragments.push(color(numberColor, m[0])); |
| 272 | lastIndex = num.lastIndex; |
| 273 | } |
| 274 | fragments.push(text.substr(lastIndex)); |
| 275 | return fragments.join(''); |
| 276 | } |
| 277 | |
| 278 | export function toErrorText(str: string) { |
| 279 | return str.split(/\r?\n/) |