@@ -271,11 +271,6 @@ def self.for(output)
271
271
end
272
272
end
273
273
274
- # When printing, you can optionally specify the value that should be used
275
- # whenever a group needs to be broken onto multiple lines. In this case the
276
- # default is \n.
277
- DEFAULT_NEWLINE = "\n "
278
-
279
274
# There are two modes in printing, break and flat. When we're in break mode,
280
275
# any lines will use their newline, any if-breaks will use their break
281
276
# contents, etc.
@@ -303,10 +298,9 @@ def self.for(output)
303
298
def self . format (
304
299
output = "" . dup ,
305
300
maxwidth = 80 ,
306
- newline = DEFAULT_NEWLINE ,
307
301
indentation = DEFAULT_INDENTATION
308
302
)
309
- q = new ( output , maxwidth , newline )
303
+ q = new ( output , maxwidth )
310
304
yield q
311
305
q . flush ( indentation )
312
306
output
@@ -329,11 +323,6 @@ def self.format(
329
323
# This defaults to 80, and should be an Integer
330
324
attr_reader :maxwidth
331
325
332
- # The value that is appended to +output+ to add a new line.
333
- #
334
- # This defaults to "\n", and should be String
335
- attr_reader :newline
336
-
337
326
# The stack of groups that are being printed.
338
327
attr_reader :groups
339
328
@@ -346,26 +335,18 @@ def self.format(
346
335
# +output+ is an output target. If it is not specified, '' is assumed. It
347
336
# should have a << method which accepts the first argument +obj+ of
348
337
# PrettierPrint#text, the first argument +separator+ of PrettierPrint#breakable,
349
- # the first argument +newline+ of PrettierPrint.new, and the result of a given
350
- # block for PrettierPrint.new.
338
+ # and the result of a given block for PrettierPrint.new.
351
339
#
352
340
# +maxwidth+ specifies maximum line length. If it is not specified, 80 is
353
341
# assumed. However actual outputs may overflow +maxwidth+ if long
354
342
# non-breakable texts are provided.
355
343
#
356
- # +newline+ is used for line breaks. "\n" is used if it is not specified.
357
- #
358
344
# The block is used to generate spaces. ->(n) { ' ' * n } is used if it is not
359
345
# given.
360
- def initialize (
361
- output = "" . dup ,
362
- maxwidth = 80 ,
363
- newline = DEFAULT_NEWLINE
364
- )
346
+ def initialize ( output = "" . dup , maxwidth = 80 )
365
347
@output = output
366
348
@buffer = Buffer . for ( output )
367
349
@maxwidth = maxwidth
368
- @newline = newline
369
350
reset
370
351
end
371
352
@@ -378,16 +359,12 @@ def initialize(
378
359
# => #<PrettierPrint:0x0>
379
360
# q.group {
380
361
# q.text q.current_group.inspect
381
- # q.text q.newline
382
362
# q.group(q.current_group.depth + 1) {
383
363
# q.text q.current_group.inspect
384
- # q.text q.newline
385
364
# q.group(q.current_group.depth + 1) {
386
365
# q.text q.current_group.inspect
387
- # q.text q.newline
388
366
# q.group(q.current_group.depth + 1) {
389
367
# q.text q.current_group.inspect
390
- # q.text q.newline
391
368
# }
392
369
# }
393
370
# }
@@ -492,11 +469,11 @@ def flush(base_indentation = DEFAULT_INDENTATION)
492
469
end
493
470
494
471
if !doc . indent?
495
- buffer << newline
472
+ buffer << " \n "
496
473
position = 0
497
474
else
498
475
position -= buffer . trim!
499
- buffer << newline
476
+ buffer << " \n "
500
477
buffer << " " * indent
501
478
position = indent
502
479
end
0 commit comments