Scribble: style adjustments to deter code wrapping

For HTML, the style used in the output of `racketblock' now
disables line wrapping, and the Rkt text styles inherit
line-wrap behavior. This doesn't solve the general problem
of code overflowing the horizontal space, but it makes the
failure mode usefully better.

A new 'vertical-inset nested-flow style is used by
`defproc', `defform', etc. It has no effect for HTML,
but it introduces suitable vertical space for Latex output
(in case you want to use `defproc' in a SIGPLAN-format
paper, for example).

original commit: 4ac85de974ec2e6326df129745228b3ffcbb778f
This commit is contained in:
Matthew Flatt 2011-08-04 18:52:13 -06:00
parent 825e3fcea8
commit 2e8e709b7f
9 changed files with 211 additions and 156 deletions

View File

@ -1271,12 +1271,15 @@
(define/override (render-nested-flow t part ri) (define/override (render-nested-flow t part ri)
`((blockquote [,@(style->attribs (nested-flow-style t)) `((blockquote [,@(style->attribs (nested-flow-style t))
,@(if (eq? 'code-inset (style-name (nested-flow-style t))) ,@(cond
`([class "SCodeFlow"]) [(eq? 'code-inset (style-name (nested-flow-style t)))
(if (and (not (string? (style-name (nested-flow-style t)))) `([class "SCodeFlow"])]
[(eq? 'vertical-inset (style-name (nested-flow-style t)))
`([class "SVInsetFlow"])]
[(and (not (string? (style-name (nested-flow-style t))))
(not (eq? 'inset (style-name (nested-flow-style t))))) (not (eq? 'inset (style-name (nested-flow-style t)))))
`([class "SubFlow"]) `([class "SubFlow"])]
null))] [else null])]
,@(append-map (lambda (i) (render-block i part ri #f)) ,@(append-map (lambda (i) (render-block i part ri #f))
(nested-flow-blocks t))))) (nested-flow-blocks t)))))

View File

@ -574,7 +574,8 @@
(let* ([kind (or (let ([s (style-name (nested-flow-style t))]) (let* ([kind (or (let ([s (style-name (nested-flow-style t))])
(or (and (string? s) s) (or (and (string? s) s)
(and (eq? s 'inset) "quote") (and (eq? s 'inset) "quote")
(and (eq? s 'code-inset) "SCodeFlow"))) (and (eq? s 'code-inset) "SCodeFlow")
(and (eq? s 'vertical-inset) "SVInsetFlow")))
"Subflow")] "Subflow")]
[props (style-properties (nested-flow-style t))] [props (style-properties (nested-flow-style t))]
[command? (memq 'command props)] [command? (memq 'command props)]

View File

@ -346,6 +346,9 @@
(parameterize ([current-meta-list '(... ...+)]) (parameterize ([current-meta-list '(... ...+)])
(make-box-splice (make-box-splice
(cons (cons
(make-blockquote
'vertical-inset
(list
(make-table (make-table
'boxed 'boxed
(append (append
@ -372,7 +375,7 @@
(*racketrawgrammars "specgrammar" (*racketrawgrammars "specgrammar"
(map car l) (map car l)
(map cdr l)))))))) (map cdr l))))))))
(make-contracts-table contract-procs))) (make-contracts-table contract-procs)))))
(content-thunk))))) (content-thunk)))))
(define (*specsubform form lits form-thunk subs sub-procs contract-procs content-thunk) (define (*specsubform form lits form-thunk subs sub-procs contract-procs content-thunk)
@ -380,6 +383,9 @@
(make-blockquote (make-blockquote
"leftindent" "leftindent"
(cons (cons
(make-blockquote
'vertical-inset
(list
(make-table (make-table
'boxed 'boxed
(cons (cons
@ -400,7 +406,7 @@
(*racketrawgrammars "specgrammar" (*racketrawgrammars "specgrammar"
(map car l) (map car l)
(map cdr l)))))))) (map cdr l))))))))
(make-contracts-table contract-procs)))) (make-contracts-table contract-procs))))))
(flow-paragraphs (decode-flow (content-thunk))))))) (flow-paragraphs (decode-flow (content-thunk)))))))
(define (*racketrawgrammars style nonterms clauseses) (define (*racketrawgrammars style nonterms clauseses)

View File

@ -464,6 +464,9 @@
(append* all-args))) (append* all-args)))
(make-box-splice (make-box-splice
(cons (cons
(make-blockquote
'vertical-inset
(list
(make-table (make-table
'boxed 'boxed
(append-map (append-map
@ -474,7 +477,7 @@
[(ormap (lambda (a) (eq? (extract-id (car ps)) a)) accum) [(ormap (lambda (a) (eq? (extract-id (car ps)) a)) accum)
(cons #f (loop (cdr ps) accum))] (cons #f (loop (cdr ps) accum))]
[else (cons #t (loop (cdr ps) [else (cons #t (loop (cdr ps)
(cons (extract-id (car ps)) accum)))])))) (cons (extract-id (car ps)) accum)))]))))))
(content-thunk)))) (content-thunk))))
(define-syntax-rule (defparam id arg contract desc ...) (define-syntax-rule (defparam id arg contract desc ...)
@ -757,7 +760,9 @@
fields field-contracts)))) fields field-contracts))))
(make-box-splice (make-box-splice
(cons (cons
main-table (make-blockquote
'vertical-inset
(list main-table))
(content-thunk)))) (content-thunk))))
;; ---------------------------------------- ;; ----------------------------------------
@ -782,6 +787,9 @@
[result-values (map (lambda (x) #f) result-contracts)]) [result-values (map (lambda (x) #f) result-contracts)])
(make-box-splice (make-box-splice
(cons (cons
(make-blockquote
'vertical-inset
(list
(make-table (make-table
'boxed 'boxed
(map (map
@ -858,7 +866,7 @@
(make-flow (list result-block))))) (make-flow (list result-block)))))
'cont)) 'cont))
null))))))) null)))))))
stx-ids names result-contracts result-values)) stx-ids names result-contracts result-values))))
(content-thunk)))) (content-thunk))))
(define (defthing/proc id contract descs) (define (defthing/proc id contract descs)

View File

@ -2,7 +2,8 @@
(require "../decode.rkt" (require "../decode.rkt"
"../scheme.rkt" "../scheme.rkt"
"../struct.rkt" "../struct.rkt"
(only-in "../core.rkt" style-name) (only-in "../core.rkt" style-name
nested-flow? nested-flow-blocks nested-flow-style)
scheme/contract scheme/contract
(for-syntax scheme/base (for-syntax scheme/base
syntax/kerncase syntax/kerncase
@ -104,21 +105,28 @@
(define (*deftogether boxes body-thunk) (define (*deftogether boxes body-thunk)
(make-box-splice (make-box-splice
(cons (cons
(make-blockquote
'vertical-inset
(list
(make-table (make-table
'boxed 'boxed
(map (map
(lambda (box) (lambda (box)
(unless (and (box-splice? box) (unless (and (box-splice? box)
(= 1 (length (splice-run box))) (= 1 (length (splice-run box)))
(table? (car (splice-run box))) (nested-flow? (car (splice-run box)))
(eq? 'boxed (style-name (table-style (car (splice-run box)))))) (eq? 'vertical-inset (style-name (nested-flow-style (car (splice-run box)))))
(let ([l (nested-flow-blocks (car (splice-run box)))])
(= 1 (length l))
(table? (car l))
(eq? 'boxed (style-name (table-style (car l))))))
(error 'deftogether (error 'deftogether
"element is not a boxing splice containing a single table: ~e" "element is not a boxing splice containing a single nested-flow with a single table: ~e"
box)) box))
(list (make-flow (list (make-table (list (make-flow (list (make-table
"together" "together"
(table-flowss (car (splice-run box)))))))) (table-flowss (car (nested-flow-blocks (car (splice-run box))))))))))
boxes)) boxes))))
(body-thunk)))) (body-thunk))))
(define-syntax (deftogether stx) (define-syntax (deftogether stx)

View File

@ -6,6 +6,7 @@
.RktMod, .RktKw, .RktVar, .RktSym, .RktMod, .RktKw, .RktVar, .RktSym,
.RktRes, .RktOut, .RktCmt, .RktVal { .RktRes, .RktOut, .RktCmt, .RktVal {
font-family: monospace; font-family: monospace;
white-space: inherit;
} }
/* Serif: */ /* Serif: */
@ -130,8 +131,17 @@
vertical-align: bottom; vertical-align: bottom;
} }
.RktBlk {
white-space: inherit;
}
.RktBlk tr {
white-space: inherit;
}
.RktBlk td { .RktBlk td {
vertical-align: baseline; vertical-align: baseline;
white-space: inherit;
} }
.argcontract td { .argcontract td {

View File

@ -365,6 +365,15 @@ i {
margin-bottom: 0em; margin-bottom: 0em;
margin-right: 0em; margin-right: 0em;
margin-top: 0em; margin-top: 0em;
white-space: nowrap;
}
.SVInsetFlow {
display: block;
margin-left: 0em;
margin-bottom: 0em;
margin-right: 0em;
margin-top: 0em;
} }
.SubFlow { .SubFlow {

View File

@ -105,6 +105,13 @@
\listparindent=0pt\itemindent=0pt\labelwidth=0pt\leftmargin=2ex\rightmargin=0pt% \listparindent=0pt\itemindent=0pt\labelwidth=0pt\leftmargin=2ex\rightmargin=0pt%
\itemsep=0pt\parsep=0pt}\item}{\end{list}\SCodePostSkip} \itemsep=0pt\parsep=0pt}\item}{\end{list}\SCodePostSkip}
% Inset a 'vertical-inset nested flow:
\newcommand{\SVInsetPreSkip}{\vskip\abovedisplayskip}
\newcommand{\SVInsetPostSkip}{\vskip\belowdisplayskip}
\newenvironment{SVInsetFlow}{\SVInsetPreSkip\begin{list}{}{\topsep=0pt\partopsep=0pt%
\listparindent=0pt\itemindent=0pt\labelwidth=0pt\leftmargin=0pt\rightmargin=0pt%
\itemsep=0pt\parsep=0pt}\item}{\end{list}\SVInsetPostSkip}
% The 'compact itemization style: % The 'compact itemization style:
\newenvironment{compact}{\begin{itemize}}{\end{itemize}} \newenvironment{compact}{\begin{itemize}}{\end{itemize}}
\newcommand{\compactItem}[1]{\item #1} \newcommand{\compactItem}[1]{\item #1}

View File

@ -558,6 +558,9 @@ names are recognized:
@item{@racket['code-inset] --- Insets the nested flow relative to @item{@racket['code-inset] --- Insets the nested flow relative to
surrounding text in a way suitable for code.} surrounding text in a way suitable for code.}
@item{@racket['vertical-inset] --- Insets the nested flow vertically
relative to surrounding text, but not horizontally.}
] ]
The following @tech{style properties} are currently recognized: The following @tech{style properties} are currently recognized: