@@ -16,7 +16,7 @@ function LineSplitter() {
16
16
this . writable = true ;
17
17
18
18
this . write = function ( data ) {
19
- var lines = ( buffer + data ) . split ( / \r \n | \n \r | \n | \r / ) ;
19
+ const lines = ( buffer + data ) . split ( / \r \n | \n \r | \n | \r / ) ;
20
20
for ( var i = 0 ; i < lines . length - 1 ; i ++ ) {
21
21
self . emit ( 'data' , lines [ i ] ) ;
22
22
}
@@ -128,18 +128,18 @@ function ParagraphParser() {
128
128
}
129
129
130
130
// Find out indentation level and the start of a lied or numbered list;
131
- var result = / ^ ( \s * ) ( \d + \. | \* | - ) ? \s * / . exec ( line ) ;
131
+ const result = / ^ ( \s * ) ( \d + \. | \* | - ) ? \s * / . exec ( line ) ;
132
132
assert . ok ( result ) ;
133
133
// The number of characters that will be stripped from the beginning of
134
134
// the line.
135
- var line_strip_length = result [ 0 ] . length ;
135
+ const line_strip_length = result [ 0 ] . length ;
136
136
// The indentation size that will be used to detect indentation jumps.
137
137
// Fudge by 1 space.
138
- var line_indent = Math . floor ( result [ 0 ] . length / 2 ) * 2 ;
138
+ const line_indent = Math . floor ( line_strip_length / 2 ) * 2 ;
139
139
// The indentation level that will be exported
140
- var level = Math . floor ( result [ 1 ] . length / 2 ) ;
140
+ const level = Math . floor ( result [ 1 ] . length / 2 ) ;
141
141
// The list indicator that precedes the actual content, if any.
142
- var line_li = result [ 2 ] ;
142
+ const line_li = result [ 2 ] ;
143
143
144
144
// Flush the paragraph when there is a li or an indentation jump
145
145
if ( line_li || ( line_indent !== paragraph_line_indent &&
@@ -175,14 +175,14 @@ inherits(ParagraphParser, Stream);
175
175
* replaces multiple consecutive whitespace characters by a single one.
176
176
*/
177
177
function Unwrapper ( ) {
178
- var self = this ;
178
+ const self = this ;
179
179
180
180
Stream . call ( this ) ;
181
181
this . writable = true ;
182
182
183
183
this . write = function ( paragraph ) {
184
- var lines = paragraph . lines ;
185
- var break_after = [ ] ;
184
+ const lines = paragraph . lines ;
185
+ const break_after = [ ] ;
186
186
var i ;
187
187
188
188
for ( i = 0 ; i < lines . length - 1 ; i ++ ) {
@@ -236,15 +236,14 @@ function RtfGenerator() {
236
236
Stream . call ( this ) ;
237
237
this . writable = true ;
238
238
239
- this . write = function ( paragraph ) {
239
+ this . write = function ( { li , level , lines , in_license_block : lic } ) {
240
240
if ( ! did_write_anything ) {
241
241
emitHeader ( ) ;
242
242
did_write_anything = true ;
243
243
}
244
244
245
- var li = paragraph . li ;
246
- var level = paragraph . level + ( li ? 1 : 0 ) ;
247
- var lic = paragraph . in_license_block ;
245
+ if ( li )
246
+ level ++ ;
248
247
249
248
var rtf = '\\pard' ;
250
249
rtf += '\\sa150\\sl300\\slmult1' ;
@@ -261,7 +260,7 @@ function RtfGenerator() {
261
260
if ( li )
262
261
rtf += ' ' + li + '\\tab' ;
263
262
rtf += ' ' ;
264
- rtf += paragraph . lines . map ( rtfEscape ) . join ( '\\line ' ) ;
263
+ rtf += lines . map ( rtfEscape ) . join ( '\\line ' ) ;
265
264
if ( ! lic )
266
265
rtf += '\\b0' ;
267
266
rtf += '\\par\n' ;
0 commit comments