(string)
| 218 | } |
| 219 | |
| 220 | function rtfEscape(string) { |
| 221 | function toHex(number, length) { |
| 222 | return (~~number).toString(16).padStart(length, '0'); |
| 223 | } |
| 224 | |
| 225 | return string |
| 226 | .replace(/[\\{}]/g, (m) => `\\${m}`) |
| 227 | .replace(/\t/g, () => '\\tab ') |
| 228 | // eslint-disable-next-line no-control-regex |
| 229 | .replace(/[\x00-\x1f\x7f-\xff]/g, (m) => `\\'${toHex(m.charCodeAt(0), 2)}`) |
| 230 | .replace(/\ufeff/g, '') |
| 231 | .replace(/[\u0100-\uffff]/g, (m) => `\\u${toHex(m.charCodeAt(0), 4)}?`); |
| 232 | } |
| 233 | |
| 234 | /* |
| 235 | * This filter generates an rtf document from a stream of paragraph objects. |
nothing calls this directly
no test coverage detected
searching dependent graphs…