| 
									
										
										
										
											2024-12-22 15:45:54 +02:00
										 |  |  | export function trimIndentation(strings: TemplateStringsArray) { | 
					
						
							| 
									
										
										
										
											2024-12-17 23:08:17 +02:00
										 |  |  |     const str = strings.toString(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Count the number of spaces on the first line.
 | 
					
						
							|  |  |  |     let numSpaces = 0; | 
					
						
							|  |  |  |     while (str.charAt(numSpaces) == ' ' && numSpaces < str.length) { | 
					
						
							|  |  |  |         numSpaces++; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-12-22 15:45:54 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Trim the indentation of the first line in all the lines.
 | 
					
						
							| 
									
										
										
										
											2024-12-17 23:08:17 +02:00
										 |  |  |     const lines = str.split("\n"); | 
					
						
							| 
									
										
										
										
											2024-12-22 15:45:54 +02:00
										 |  |  |     const output = []; | 
					
						
							| 
									
										
										
										
											2024-12-17 23:08:17 +02:00
										 |  |  |     for (let i=0; i<lines.length; i++) { | 
					
						
							|  |  |  |         let numSpacesLine = 0; | 
					
						
							|  |  |  |         while (str.charAt(numSpacesLine) == ' ' && numSpacesLine < str.length) { | 
					
						
							|  |  |  |             numSpacesLine++; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         output.push(lines[i].substring(numSpacesLine)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return output.join("\n"); | 
					
						
							| 
									
										
										
										
											2024-12-22 15:45:54 +02:00
										 |  |  | } |