commit 5b37a3ac7290363e561473668b58b63fe325ee82
parent aca15dcc852d4b6291cc49f3cb821a8273abc3e3
Author: Matthew Flatt <mflatt@racket-lang.org>
Date: Fri, 5 Aug 2016 09:25:37 -0600
examples: avoid generating an empty nested table for empty output
For something like
#lang scribble/manual
@(require scribble/eval)
@interaction[(define x 2)
x]
the `interaction` form generated an empty nested table for the zero
results from `define`. When rendering via Latex, that empty table
could create vertical whitespace. Produce zero lines in the enclosing
table, instead.
Diffstat:
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/scribble-lib/scribble/eval.rkt b/scribble-lib/scribble/eval.rkt
@@ -99,13 +99,15 @@
[(eof-object? v)
(let* ([line-accum (add-string string-accum line-accum)]
[flow-accum (add-line line-accum flow-accum)])
- (list
- (list.flow.list
- (if (= 1 (length flow-accum))
- (car flow-accum)
- (make-table
- #f
- (map list.flow.list (reverse flow-accum)))))))]
+ (if (null? flow-accum)
+ null
+ (list
+ (list.flow.list
+ (if (= 1 (length flow-accum))
+ (car flow-accum)
+ (make-table
+ #f
+ (map list.flow.list (reverse flow-accum))))))))]
[(equal? #\newline v)
(loop #f #f (add-line (add-string string-accum line-accum)
flow-accum))]