Optionally omit commas when writing preserves
This commit is contained in:
parent
8b2aa0fb87
commit
6c9071fd88
|
@ -26,6 +26,7 @@
|
||||||
(define (write-preserve/text v0 [o (current-output-port)]
|
(define (write-preserve/text v0 [o (current-output-port)]
|
||||||
#:indent [indent-amount0 #f]
|
#:indent [indent-amount0 #f]
|
||||||
#:encode-embedded [encode-embedded0 #f]
|
#:encode-embedded [encode-embedded0 #f]
|
||||||
|
#:commas? [commas? #t]
|
||||||
#:write-annotations? [write-annotations? #t])
|
#:write-annotations? [write-annotations? #t])
|
||||||
(define encode-embedded (or encode-embedded0 object-id))
|
(define encode-embedded (or encode-embedded0 object-id))
|
||||||
(define indent-amount (match indent-amount0
|
(define indent-amount (match indent-amount0
|
||||||
|
@ -164,9 +165,9 @@
|
||||||
[_ (write-stringlike-char c)]))
|
[_ (write-stringlike-char c)]))
|
||||||
(! "|")))]
|
(! "|")))]
|
||||||
[(record label fields) (write-record distance label fields)]
|
[(record label fields) (write-record distance label fields)]
|
||||||
[(? list?) (write-sequence distance "[" "," "]" write-value v)]
|
[(? list?) (write-sequence distance "[" (if commas? "," "") "]" write-value v)]
|
||||||
[(? set?) (write-sequence distance "#{" "," "}" write-value (set->list v))]
|
[(? set?) (write-sequence distance "#{" (if commas? "," "") "}" write-value (set->list v))]
|
||||||
[(? dict?) (write-sequence distance "{" "," "}" write-key-value (dict->list v))]
|
[(? dict?) (write-sequence distance "{" (if commas? "," "") "}" write-key-value (dict->list v))]
|
||||||
[other
|
[other
|
||||||
(! "#!")
|
(! "#!")
|
||||||
(write-value distance (encode-embedded other))]))
|
(write-value distance (encode-embedded other))]))
|
||||||
|
@ -176,9 +177,11 @@
|
||||||
(define (preserve->string v0
|
(define (preserve->string v0
|
||||||
#:indent [indent-amount #f]
|
#:indent [indent-amount #f]
|
||||||
#:encode-embedded [encode-embedded #f]
|
#:encode-embedded [encode-embedded #f]
|
||||||
|
#:commas? [commas? #t]
|
||||||
#:write-annotations? [write-annotations? #t])
|
#:write-annotations? [write-annotations? #t])
|
||||||
(with-output-to-string
|
(with-output-to-string
|
||||||
(lambda () (write-preserve/text v0
|
(lambda () (write-preserve/text v0
|
||||||
#:indent indent-amount
|
#:indent indent-amount
|
||||||
#:encode-embedded encode-embedded
|
#:encode-embedded encode-embedded
|
||||||
|
#:commas? commas?
|
||||||
#:write-annotations? write-annotations?))))
|
#:write-annotations? write-annotations?))))
|
||||||
|
|
Loading…
Reference in New Issue