From 2af626972de3041951ef9efdbdbb216b6031cc72 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sun, 22 Mar 2009 01:26:15 +0000 Subject: [PATCH] There is a problem with empty lines: having a line (= a row) in the code tables with empty contents makes the row not appear. Usually, we'd put an   there so it does show, but that would be bad for the preprocessor examples where I really want to have the table contents reflect the exact file contents. So another solution is to use a 'newline element, but then latex barfs because it's not happy with a \\ inside a tt macro. The hacked "solution" is to have the newline element not be inside a tt element -- latex doesn't barf now, but it does have one extra newline as a result since it doesn't hide the newline to begin with. A better solution is to find a way to make table cells in html not be hidden when they have no contents, maybe through some css magic. svn: r14206 --- collects/scribblings/scribble/utils.ss | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/collects/scribblings/scribble/utils.ss b/collects/scribblings/scribble/utils.ss index b51fe4d09e..abf1581aeb 100644 --- a/collects/scribblings/scribble/utils.ss +++ b/collects/scribblings/scribble/utils.ss @@ -110,15 +110,17 @@ (define strs2 (split out-text)) (define strsm (map (compose split cdr) more)) (define (str->elts str) + (let ([spaces (regexp-match-positions #rx"(?:^| ) +" str)]) + (if spaces + (list* (substring str 0 (caar spaces)) + (hspace (- (cdar spaces) (caar spaces))) + (str->elts (substring str (cdar spaces)))) + (list (make-element 'tt (list str)))))) + (define (make-line str) (if (equal? str "") - (list (make-element 'newline (list ""))) - (let ([spaces (regexp-match-positions #rx"(?:^| ) +" str)]) - (if spaces - (list* (substring str 0 (caar spaces)) - (hspace (- (cdar spaces) (caar spaces))) - (str->elts (substring str (cdar spaces)))) - (list (make-element 'tt (list str))))))) - (define (make-line str) (list (as-flow (make-element 'tt (str->elts str))))) + ;;FIXME: this works in html, but in latex it creates a redundant newline + (list (as-flow (make-element 'newline '()))) + (list (as-flow (make-element 'tt (str->elts str)))))) (define (small-attr attr) (make-with-attributes attr '([style . "font-size: 82%;"]))) (define (make-box strs)