1 | 'use strict';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | const stringifyComment = (str) => str.replace(/^(?!$)(?: $)?/gm, '#');
|
11 | function indentComment(comment, indent) {
|
12 | if (/^\n+$/.test(comment))
|
13 | return comment.substring(1);
|
14 | return indent ? comment.replace(/^(?! *$)/gm, indent) : comment;
|
15 | }
|
16 | const lineComment = (str, indent, comment) => str.endsWith('\n')
|
17 | ? indentComment(comment, indent)
|
18 | : comment.includes('\n')
|
19 | ? '\n' + indentComment(comment, indent)
|
20 | : (str.endsWith(' ') ? '' : ' ') + comment;
|
21 |
|
22 | exports.indentComment = indentComment;
|
23 | exports.lineComment = lineComment;
|
24 | exports.stringifyComment = stringifyComment;
|