Skip to content

Commit a5e2c8a

Browse files
committed
Cleanup duplicate newlines from output comments
1 parent 23952fd commit a5e2c8a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/utils/string.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ export function removeNewlines(text: string) {
2222
* Puts a comment before each line in a string
2323
*/
2424
export function putCommentBeforeEachLine(text: string, skipLineOne: boolean = true) {
25+
// Remove duplicate consequitive new lines.
26+
while (text.match(/\r?\n\r?\n\r?\n/g)) {
27+
text = text.replace(/\r?\n\r?\n\r?\n/g, "\n\n");
28+
}
29+
2530
return text.split(/\r?\n/g).map((line, index) => {
2631
if (index === 0 && skipLineOne)
2732
return line;

0 commit comments

Comments
 (0)