Skip to content

Commit ca5f4f0

Browse files
PierluigiIannarelliMylesBorins
authored andcommitted
tools: use more template literals
PR-URL: #15942 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent e12dc40 commit ca5f4f0

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

tools/license2rtf.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,22 +245,19 @@ function RtfGenerator() {
245245
if (li)
246246
level++;
247247

248-
var rtf = '\\pard';
249-
rtf += '\\sa150\\sl300\\slmult1';
248+
var rtf = '\\pard\\sa150\\sl300\\slmult1';
250249
if (level > 0)
251-
rtf += '\\li' + (level * 240);
250+
rtf += `\\li${level * 240}`;
252251
if (li) {
253-
rtf += '\\tx' + (level) * 240;
254-
rtf += '\\fi-240';
252+
rtf += `\\tx${level * 240}\\fi-240`;
255253
}
256254
if (lic)
257255
rtf += '\\ri240';
258256
if (!lic)
259257
rtf += '\\b';
260258
if (li)
261-
rtf += ' ' + li + '\\tab';
262-
rtf += ' ';
263-
rtf += lines.map(rtfEscape).join('\\line ');
259+
rtf += ` ${li}\\tab`;
260+
rtf += ` ${lines.map(rtfEscape).join('\\line ')}`;
264261
if (!lic)
265262
rtf += '\\b0';
266263
rtf += '\\par\n';
@@ -279,25 +276,25 @@ function RtfGenerator() {
279276
function toHex(number, length) {
280277
var hex = (~~number).toString(16);
281278
while (hex.length < length)
282-
hex = '0' + hex;
279+
hex = `0${hex}`;
283280
return hex;
284281
}
285282

286283
function rtfEscape(string) {
287284
return string
288285
.replace(/[\\{}]/g, function(m) {
289-
return '\\' + m;
286+
return `\\${m}`;
290287
})
291288
.replace(/\t/g, function() {
292289
return '\\tab ';
293290
})
294291
// eslint-disable-next-line no-control-regex
295292
.replace(/[\x00-\x1f\x7f-\xff]/g, function(m) {
296-
return '\\\'' + toHex(m.charCodeAt(0), 2);
293+
return `\\'${toHex(m.charCodeAt(0), 2)}`;
297294
})
298295
.replace(/\ufeff/g, '')
299296
.replace(/[\u0100-\uffff]/g, function(m) {
300-
return '\\u' + toHex(m.charCodeAt(0), 4) + '?';
297+
return `\\u${toHex(m.charCodeAt(0), 4)}?`;
301298
});
302299
}
303300

0 commit comments

Comments
 (0)