mirror of
				https://github.com/flynx/colors.js.git
				synced 2025-10-31 12:00:08 +00:00 
			
		
		
		
	Add multiline handling functionality
Allows multiline logs to have each line styled properly.
This commit is contained in:
		
							parent
							
								
									dc82cc01d0
								
							
						
					
					
						commit
						172098b1f5
					
				| @ -107,12 +107,23 @@ function applyStyle() { | ||||
|   var nestedStyles = this._styles; | ||||
| 
 | ||||
|   var i = nestedStyles.length; | ||||
|   | ||||
|   var rebuiltString = ''; | ||||
| 
 | ||||
|   while (i--) { | ||||
|     var code = ansiStyles[nestedStyles[i]]; | ||||
|     str = code.open + str.replace(code.closeRe, code.open) + code.close; | ||||
| 
 | ||||
|     // multiline handling functionality
 | ||||
|     var lines = str.split(/[\r\n]+/) | ||||
|     var rebuiltString = ''; | ||||
|     lines.forEach(line => { | ||||
|       rebuiltString += (code.open + line.replace(code.closeRe, code.open) + code.close + '\n') | ||||
|     }) | ||||
|      | ||||
|   } | ||||
| 
 | ||||
|   return str; | ||||
|   return rebuiltString; | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| colors.setTheme = function (theme) { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user