|
@ -245,22 +245,19 @@ function RtfGenerator() { |
|
|
if (li) |
|
|
if (li) |
|
|
level++; |
|
|
level++; |
|
|
|
|
|
|
|
|
var rtf = '\\pard'; |
|
|
var rtf = '\\pard\\sa150\\sl300\\slmult1'; |
|
|
rtf += '\\sa150\\sl300\\slmult1'; |
|
|
|
|
|
if (level > 0) |
|
|
if (level > 0) |
|
|
rtf += '\\li' + (level * 240); |
|
|
rtf += `\\li${level * 240}`; |
|
|
if (li) { |
|
|
if (li) { |
|
|
rtf += '\\tx' + (level) * 240; |
|
|
rtf += `\\tx${level * 240}\\fi-240`; |
|
|
rtf += '\\fi-240'; |
|
|
|
|
|
} |
|
|
} |
|
|
if (lic) |
|
|
if (lic) |
|
|
rtf += '\\ri240'; |
|
|
rtf += '\\ri240'; |
|
|
if (!lic) |
|
|
if (!lic) |
|
|
rtf += '\\b'; |
|
|
rtf += '\\b'; |
|
|
if (li) |
|
|
if (li) |
|
|
rtf += ' ' + li + '\\tab'; |
|
|
rtf += ` ${li}\\tab`; |
|
|
rtf += ' '; |
|
|
rtf += ` ${lines.map(rtfEscape).join('\\line ')}`; |
|
|
rtf += lines.map(rtfEscape).join('\\line '); |
|
|
|
|
|
if (!lic) |
|
|
if (!lic) |
|
|
rtf += '\\b0'; |
|
|
rtf += '\\b0'; |
|
|
rtf += '\\par\n'; |
|
|
rtf += '\\par\n'; |
|
@ -279,25 +276,25 @@ function RtfGenerator() { |
|
|
function toHex(number, length) { |
|
|
function toHex(number, length) { |
|
|
var hex = (~~number).toString(16); |
|
|
var hex = (~~number).toString(16); |
|
|
while (hex.length < length) |
|
|
while (hex.length < length) |
|
|
hex = '0' + hex; |
|
|
hex = `0${hex}`; |
|
|
return hex; |
|
|
return hex; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function rtfEscape(string) { |
|
|
function rtfEscape(string) { |
|
|
return string |
|
|
return string |
|
|
.replace(/[\\{}]/g, function(m) { |
|
|
.replace(/[\\{}]/g, function(m) { |
|
|
return '\\' + m; |
|
|
return `\\${m}`; |
|
|
}) |
|
|
}) |
|
|
.replace(/\t/g, function() { |
|
|
.replace(/\t/g, function() { |
|
|
return '\\tab '; |
|
|
return '\\tab '; |
|
|
}) |
|
|
}) |
|
|
// eslint-disable-next-line no-control-regex
|
|
|
// eslint-disable-next-line no-control-regex
|
|
|
.replace(/[\x00-\x1f\x7f-\xff]/g, function(m) { |
|
|
.replace(/[\x00-\x1f\x7f-\xff]/g, function(m) { |
|
|
return '\\\'' + toHex(m.charCodeAt(0), 2); |
|
|
return `\\'${toHex(m.charCodeAt(0), 2)}`; |
|
|
}) |
|
|
}) |
|
|
.replace(/\ufeff/g, '') |
|
|
.replace(/\ufeff/g, '') |
|
|
.replace(/[\u0100-\uffff]/g, function(m) { |
|
|
.replace(/[\u0100-\uffff]/g, function(m) { |
|
|
return '\\u' + toHex(m.charCodeAt(0), 4) + '?'; |
|
|
return `\\u${toHex(m.charCodeAt(0), 4)}?`; |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|